Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic field population in web forms 1

Status
Not open for further replies.

Katie6

Programmer
Jun 12, 2007
58
GB

Hi there, I have never used javascript before, and I was wondering if any of you clever people would be able to help me work out the following problem?

I have created a form in html. In the first field, the user will enter a number, e.g. 5. I would like this number (in this case 5) to automatically appear in the next field, and I would like the automatically filled-in field to remain editable.

I have been told that this can be done in javascript, but no-one in the department knows how!

I hope I have given you the information you need, but let me know if I've left anything out.

Many thanks for your help,

Katie.
 
Hi Katie,

try something like this:

Add within <head> tag
Code:
<script language="javascript">
function AddValue(ValueToAdd){
document.getElementById('Field2').value = ValueToAdd;
}
</script>

Add with <body>
Code:
<input type="text" id="Field1" onchange="AddValue(this.value);">
<input type="text" id="Field2">

Cheers

Nick
 
Thank you so much Nick!!! That's great :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top