View Single Post
  #43  
Old 02-21-2008, 01:41 AM
prasannavigneshr prasannavigneshr is offline
D-Web Incredible
 
Join Date: Feb 2007
Posts: 1,264
prasannavigneshr is on a distinguished road
Send a message via MSN to prasannavigneshr
Thumbs up ColdFusion Tips & Tricks - Populating Text fields based off a drop-down selection bo

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>
__________________
Prasanna Vignesh
MCPD | Web Developer
Reply With Quote