Populating Text fields based off a drop-down selection box
If you want to auto-populate certain text fields based off a section in a drop-down selection box, you can use the code below as an example.
This example will populate a text box with the month selected in the drop-down selection box.
Example HTML/CFML code: Code:
<html>
<head>
<script language="Javascript">
function Populate(idx)
{
MonthList = new Array('January','Feburary','March','April','May','June','July','August','September','October','November','December');
document.MyForm.Month2.value=MonthList[idx];
}
</script>
</head>
<body>
<form name="MyForm">
Select a month:
<select name="Month1" size="1" onChange="Populate(this.selectedIndex)">
<CFLOOP index="loop" from="1" to="12">
<CFOUTPUT><option>#loop#</option></CFOUTPUT>
</CFLOOP>
</select>
<br>
You selected the month of
<input type="Text" name="Month2">
</form>
</body>
</html>