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

Dynamic Dropdown

P: 1
I have created a dynamic drop down menu which ha worked very well. How can i resubmit whatever single thing i select back to a different table in the same database like i would in a mere html drop-down menu.
Nov 29 '11 #1
Share this Question
Share on Google+
1 Reply

P: 1,059
If you want to select a specific item in a drop down list you will have to draw it like below:
Expand|Select|Wrap|Line Numbers
  1. <SELECT>
    <OPTION value='a'>a</option>
    <OPTION value='b' SELECTED>b</option>
    <OPTION value='c'>c</option>
if you want to do it in php, it can be like this
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  $selected='b';
  3.  $arr[0]='a';
  4.  $arr[1]='b';
  5.  $arr[2]='c';
  6. ?>
  7.  <SELECT>
  8. <?php
  9.  for($i=0;i<3;i++)
  10.  {
  11.   if($arr[i]==$selected) 
  12.    $sel='SELECTED';
  13.   else $sel='';
  14.  ?>
  15.   <OPTION value='<?=$arr[$i]?>' <?=$sel?>><?=$arr[$i]?></OPTION>
  16.  <?php
  17.  } 
  18. ?>
  19.  </SELECT>
Nov 30 '11 #2

Post your reply

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