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

How to fill textbox based on combobox selection ?

P: 2
hi

Expand|Select|Wrap|Line Numbers
  1.    <select name="jobCode" class=comboBox id="jobCode">
  2.    <?php
  3.    $jobCodeQuery="select * from jobcodecreation";
  4.    $jobcodeResult = mysql_query($jobCodeQuery);
  5.    echo "<option value=\"\" selected></option>";
  6.    $jobCodeVal=1;                           
  7.    while($nt=mysql_fetch_array($jobcodeResult))
  8.    {
  9.    echo "<option value=$jobCodeVal>$nt[jobcode]/option>";
  10.    $jobCodeVal++;
  11.    }
  12.    ?>
  13.    </select>
  14.    <input type="text" name="jobTitle" id="jobTitle"  maxlength="30" class="textBoxWidth"/>
  15.    <input type="text" name="jobrole" id="jobrole" maxlength="30" class="textBoxWidth"/>
  16.  
here i fetched the values from database for filling the jobCode (dropdownlist),based on the selected value of jobCode (dropdownlist) the jobtitle,jobrole (textbox) value should be fetched from same table and filled in the above textbox(jobtitle,jobrole).Please help me in providing the solution.
Jan 11 '11 #1
Share this Question
Share on Google+
3 Replies


100+
P: 1,059
Try javascript.

1. Read Data from Select box on javascript
onchange action

2. Write the data to text box.
Jan 11 '11 #2

AutumnsDecay
100+
P: 170
I don't fully understand the question, however on line 9 you have:

Expand|Select|Wrap|Line Numbers
  1. echo "<option value=$jobCodeVal>$nt[jobcode]/option>";
You're missing a '<' to close the option element.
Jan 11 '11 #3

P: 2
i mistyped it
Expand|Select|Wrap|Line Numbers
  1.  <select name="jobCode" class=comboBox id="jobCode">
  2.     <?php
  3.     $jobCodeQuery="select * from jobcodecreation";
  4.     $jobcodeResult = mysql_query($jobCodeQuery);
  5.     echo "<option value=\"\" selected></option>";
  6.     $jobCodeVal=1;                           
  7.     while($nt=mysql_fetch_array($jobcodeResult))
  8.     {
  9.     echo "<option value=$jobCodeVal>$nt[jobcode]</option>";
  10.     $jobCodeVal++;
  11.     }
  12.     ?>
  13.     </select>
  14.     <input type="text" name="jobTitle" id="jobTitle"  maxlength="30" class="textBoxWidth"/>
  15.     <input type="text" name="jobrole" id="jobrole" maxlength="30" class="textBoxWidth"/>
  16.  
But the problem is how to get the textbox to be filled based the combobox selected value
Jan 12 '11 #4

Post your reply

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