By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,575 Members | 3,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,575 IT Pros & Developers. It's quick & easy.

getting selected item of drop down box

P: 59
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

Expand|Select|Wrap|Line Numbers
  1. <select>
  2.   <option value="Item 1">A</option>
  3.   <option value="Item 2">B2</option>
  4.   <option value="Item 3">C</option>
  5. </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
Mar 18 '08 #1
Share this Question
Share on Google+
1 Reply


P: 32
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

Expand|Select|Wrap|Line Numbers
  1. <select>
  2.   <option value="Item 1">A</option>
  3.   <option value="Item 2">B2</option>
  4.   <option value="Item 3">C</option>
  5. </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.
Mar 18 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.