Thanks Pablo,
I wound up with this...
<select size="1" name="customer">
<option value='none:none'>NONE</option>
<?PHP
while($query_data1=mysql_fetch_row($result1)){
echo"<option value='$query_data1[0]:$query_data1[1]'>
$query_data1[1]</option>";
}
?>
Then I simply do:
$array = explode(":",$_POST['customer']);
Then when I do the database update I just need to put $array[0],
$array[1] into the fields in the database.
Thanks,
Jeff
> -----Original Message-----
> From: Pablo Gosse [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 13, 2003 3:27 PM
> To: Jeff McKeon; [EMAIL PROTECTED]
> Subject: RE: [PHP] Multiple values in a form option field
>
>
> On Thursday, November 13, Jeff wrote:
>
> [snip]What I now need to do is store not only the userID but
> the email address as well. Is there a way using a form to
> store 2 values using one drop down box? So basically I want
> to store the userID and the Email address to a variable in
> the form so that both may be written to different fields in
> the database later.[/snip]
>
> Hi Jeff. For this you'll need to use javascript and hidden
> form fields. I've had to do this in a few places in my CMS
> and it's not too difficult.
>
> The Javascript will be something like this:
>
> <script type="text/javascript">
> <!--
> // x is the select list in question
> function setEmail(x)
> {
> var users = new Array();
> <?php
> $count = 0;
> foreach ($users as $id=>$user)
> {
> echo 'users['.$count.'] = '.$id.';';
> $count++;
> }
> ?>
>
> for (i=0;i<x.length;i++)
> {
> if (x.options[i].selected) hiddenidfield.value =
> users[i];
> }
> }
> //-->
> </script>
>
> One thing to make sure of is that you are looping through
> your results in the same order both when you create the
> javascript array inside the function, and also when creating
> the select list.
>
> Then in your form have a hidden input as follows:
>
> <input type="hidden" name="id">
>
> And for the select list, use the onchange attribute to set
> the value of the hidden input field (onchange="setEmail(this);").
>
> You'll obviously need to update hiddenidfield.value with the
> proper reference to this input in the elements collection for
> this form.
>
> I'm writing this off the top of my head, so if there are any
> problems let me know. It should be pretty close though as I
> had to do just what you asked a few times recently.
>
> Cheers,
> Pablo
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php