OK, I have a HTML option box with roughly 500 options, and I want to make 2 PHP variables from the optons. This is hard to explain, so I'll just show you: <option value="1">James</option> HTML: So from that example I want to get 2 variables: $name and $code $code should equal "1" (the value) and $name should equal "James" (the displayed option). I know how to use POST to get the value, but not the text the option displays. Thanks, BP
here is trick to do this make your form like this <select name="pizza"> <option value="1***James" >James</option> . . . </select> HTML: and then do use the explode statement to separate them on the next page $pieces = explode("***", $pizza); PHP: now you have two values $pieces[0] = 1; $pieces[1] = James; PHP:
Thanks for the help, but I would rather not have to change 500 different options to make it like that. And the PHP code already has the variables $code and $name defined, so I would rather use those 2, instead of using $code[0], $code[1]/ However, if their is no other alternative, I will do it like this, Thanks, BP
You cannot get the text the option displays. You have to use the method ravish showed or in your PHP code you will need a condition. Like if $code == 1 then $name = "James";
You could create a key eg: $key[1] = 'James'; $key[2] = 'Jim'; PHP: or $key = array('James', 'Jim', ...); PHP: