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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please another select box question

Status
Not open for further replies.

crimmelcp

Programmer
Oct 13, 2004
31
0
0
US
Please help:
How can I get the text boxes to populate from the select box.
Thanks
Charlie Crimmel

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>

</head>
<BR>

<body>
<cfscript>    qNames = queryNew("id,craft,crdesc,wage,otwage");    
queryAddRow(qNames);    querySetCell(qNames, "id", "1");    querySetCell(qNames, "craft", "451");    querySetCell(qNames, "crdesc", "ELGF");    querySetCell(qNames, "wage", "20.00");    querySetCell(qNames, "otwage", "30.00");    
queryAddRow(qNames);    querySetCell(qNames, "id", "2");    querySetCell(qNames, "craft", "452");    querySetCell(qNames, "crdesc", "ELF");    querySetCell(qNames, "wage", "15.00");    querySetCell(qNames, "otwage", "22.00");    
queryAddRow(qNames);    querySetCell(qNames, "id", "3");    querySetCell(qNames, "craft", "453");    querySetCell(qNames, "crdesc", "ELJ");    querySetCell(qNames, "wage", "10.00");    querySetCell(qNames, "otwage", "15.00");   
queryAddRow(qNames);    querySetCell(qNames, "id", "4");    querySetCell(qNames, "craft", "454");    querySetCell(qNames, "crdesc", "ELA60");    querySetCell(qNames, "wage", "8.00");    querySetCell(qNames, "otwage", "12.00"); 
</cfscript>

<table width="100%">
<CFFORM name="MyForm"  format="flash" skin="halogreen" preloader="no"  method="post" enctype="multipart/form-data" height="800" width="100%" preservedata="Yes">
<cfformgroup type="vdividedbox" width="100%">
<cfformgroup type="hbox" width="100%">
  	<cfformgroup type="hbox">
	<cfformgroup type="panel" Label="Craft Data">
	<cfselect name="selectwage" message="Select Craft" 
	query="qNames"
	value="Craft"
    display="Craft"
    required="NO"
    multiple="NO"
	selected=""
    size="1"
	label="Change Empl Craft">
</cfselect>
	<cfinput name="Craft" type="text" label="Craft" width="100" >
	<cfinput name="Crdesc" type="text" label="Crdesc" width="100" >
	<cfinput name="Wage" type="text" label="Wage" width="100" >
	<cfinput name="OTWage" type="text" label="OTWage" width="100" >
	</cfformgroup></cfformgroup>
</cfformgroup></cfformgroup>
</CFFORM>	
</body>
</html>
 
You want to populate the text box depending on what they select in the select box? If so, you will need to use javascript because that will need to happen after Coldfusion has generated the HTML (and thus ColdFusion is out of the picture at that point). If that is what you want it has been asked many times on the javascript forum so just do a search there. If I am completely wrong on what you want let me know.


Keith


The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents.
 
ok, first things first.
there are 2 ways to do it. you'll have to choose which way you want to do it.

1) select the value, use javascript to reload the page, use the dropdown value in a query to get the data for the text fields.
pros:
easier to code
only one record is returned from your database
Cons:
the page has to be refreshed onchange by making a trip to the server.

2) load all the data into a javascript array, use javascript to make the change without having to reload the page. ( forum216 search first like klaforc said )
pros:
fields are updated without having to make a trip to the server.
Cons:
every record has to be pulled from the database to populate the js array.
harder to code.

a con to both of these options is if javascript is turned off neither will work.

Beware of programmers who carry screwdrivers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top