|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
Hello All,
I am just developing my PHP skills and was wondering if anyone can answer a problem i'm having... I've got a PHP page that includes a form, and one of the elements on the form is a drop down list. When the user selects an option I would like the value of the option selected to go into a PHP variable, so that I can send it in a URL link. [The Code] <?php $contactResults = mysql_query("SELECT * from contacts order by contactname"); ?> <td width="33%" align="center" class="place_center"> <b>Contact Details</b><br> <select name="companycontact" onChange=""> <option value="test" selected>Contact Name</option> <?php do { $options = $myrow["contactname"] . ", " . $myrow["companyname"]; printf("<option value=\"%s\">%s</option>\n", $myrow["contactid"], $options); } while ($myrow = mysql_fetch_array($contactResults)); ?> </select><br> <?php echo "<a href=\"#\" onClick=\"window.open('view.contact.php?conid=" . $companycontact . "','newwindow','HEIGHT=400,WIDTH=250,left=0,top=110 ,scrollbars=1,location=1')\"><b>View Contact</b></a>"; ?> [/The_Code] I haven't included any of my connections to the DB and the main form tag, but i don't think this is required. If this will be beneficial, please let me know and I shall post this as well... Thanks for your help, Harvey |
|
#2
|
|||
|
|||
|
Quote:
It automatically will be as when the form is submitted, the script will be able to get the value using $_POST or $_GET -> whichever your form method is set to. So, if your 'Form Select Menu' is named 'menu' and you have an option in the 'menu' that says 'cheeseburger' and the value of that option is '1' -> when the user selects 'cheeseburger' and your form method is 'get', your php scalar will look like this -> PHP Code:
PS: Not sure if that is what you are looking for...
__________________
~ Joe Penn We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set? Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you. |
|
#3
|
|||
|
|||
|
Thanks for the reply, but...
...I would like to recieve the [form] option selected before the form has been submitted. I was thinking if I could get the option selected into a PHP varable in the onChange event for the [form]SELECT menu?? Thanks for your help... Harvey |
|
#4
|
||||
|
||||
|
Why would you want to recieve the value of the form before it is submitted? Are you wanting to have dynamic code so that if you choose one thing, say, cheeseburger, it will make another form visible for toppings, or if you choose a taco if it gives the option of hotsauce?
The only way I could imagine for you to recieve the value is if you were using javascript and an on change to make the other form visible, if thats what you're wanting to do.. |
|
#5
|
|||
|
|||
|
Ya - I think he might be looking for 'livescript' - asp thing, but not sure if that is exactly what it is called. I remember seeing an article on it somewhere - but can't remember where. One site that uses it is progressive.com; when filling out the auto insurance forms - the livescript tags the db to draw the info for the automobile specifics based on the selections prior...
|
|
#6
|
||||
|
||||
|
Thats what I thought but I couldn't quite place it..
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Capturing data from form drop down list when form has not been submitted |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|