Quote:
Originally Posted by gubbachchi
Hi,
How can I get the selected item of the drop down box into a php variable in the same page. The options in drop down box are A,B and C and the code is here
- <select>
-
<option value="Item 1">A</option>
-
<option value="Item 2">B2</option>
-
<option value="Item 3">C</option>
-
</select>
When the user selects an option from the drop down box, I need that value in the php variable in the same page. And I don't need the submit button, as soon as the user selects item from drop down box the selected item should be in php variable. And I want to do this without using javascript's onchange function. Can I do this only using php.
Does anybody has some idea about this. Please help me.
With regards
PHP is executed before the page loads (Hypertext
Preprocessor). It means that PHP execution is completed before the user can even see the select box.
Doing what you want would require refreshing the page everytime the user select an item (re-execute the PHP so your code can know what was selected) or using an iframe or using... javascript.
HTH.