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

how to get item name in combo or list box from its index using php.here i try in js

P: 19
but this doesn't give answer....
Expand|Select|Wrap|Line Numbers
  1. function fun_month()
  2. {
  3. var temp = document.getElementById("list_month").selectedIndex;
  4. alert(temp);
  5.  
  6. selected_month = document.getElementById("list_month").options[temp].value;
  7.  
  8. alert(selected_month);
  9. }
  10.  
Apr 8 '12 #1

✓ answered by johny10151981

in a combo box there is two thing
1. the value and
2. the text
Expand|Select|Wrap|Line Numbers
  1. <select id='dd'>
  2.  <option value='1'>111</option>
  3.  <option value='2'>222</option>
  4. </select>
  5.  
if you do
document.getElementById('dd').value
you would get either 1 or 2.

your form would send the value of selected item to server.

Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,364
Why are you giving us javascript if you're trying to do it in PHP? Where's your PHP code?

Just so you know, you can't really do this in PHP. But why would you want to? What's the point of passing the selected index to PHP when you can just pass the selected value?
Apr 8 '12 #2

100+
P: 1,059
in a combo box there is two thing
1. the value and
2. the text
Expand|Select|Wrap|Line Numbers
  1. <select id='dd'>
  2.  <option value='1'>111</option>
  3.  <option value='2'>222</option>
  4. </select>
  5.  
if you do
document.getElementById('dd').value
you would get either 1 or 2.

your form would send the value of selected item to server.
Apr 9 '12 #3

P: 19
i want to get value so i try to get index and then by using that index i want to get a value so only i raise a question..
johny give a exact answer for that thanks...
but using index too, i get value..
but johny method is simple..
Apr 14 '12 #4

Post your reply

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