Jump to content

mysql filled Dropdownbox needs to populate multiple textboxes onchange


cjkeane

Recommended Posts

Hi everyone.

 

I have a combo box which lists usernames and onchange, the username value is passed to a textbox. however, I have 3 textboxes i need to populate based on the selection of the combobox: username. department and email. i have the username going into a textbox, but i'm not sure how to pass department and email into two other textboxes.

 

I'd appreciate any help you could provide. Thanks.

 

<script>
function CBtoTB()
{document.getElementById("username").value=document.getElementById("usernameselect").value}
</script>

<?php  
$result=mysql_query("select Username, EMail, Department from users"); 
$options=""; 
while ($row=mysql_fetch_array($result)) { 
$username=$row["Username"]; 
$options.="<OPTION VALUE=\"$username\">".$username.'</option>'; 
} 
?>
<select name="usernameselect" id="usernameselect" onchange="CBtoTB()">
<option value="">< select user ><?php echo $options ?></option>
</select>
<input name="username" type="text" id="username" value="<?php echo $username ?>" size="25" readonly="readonly" />

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.