Jump to content

How to auto-populate text box with selection made from a drop-down list


JohnCP
 Share

Recommended Posts

Hi all, I think my topic title describes my question. I can't seem to figure out how to auto-populate a text box that is right below a drop-down field. When the user selects an item from the drop-down, the selected item should auto populate the text box.Any help is greatly appreicated.Thanks,JP

Link to comment
Share on other sites

HMTL

...<select id="ddl" onchange="autoFill(this)">...options...</select><br/><input type="text" id="txt" value=""/>

js

function autoFill(ddl){  var txt = document.getElementById("txt");  txt.value = ddl.options[ddl.selectedIndex].value;}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...