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!

Cant populate and disable text boxes according to DD value selected!!

Status
Not open for further replies.

countdrak

Programmer
Jun 20, 2003
358
0
0
US
Here is what I am trying to do.

I have a Car Information table. I have four fields- Car_id,Car_Description, Car_Make, Car_Model.

Now I have a coldfusion form with a drop down list that I poulate witht he descriptions. And then I have text-fields for the other three fields.
Now lets say we have Car_Descrption=Blue Car , Car_Make=Ford
Car_Model=Mustang and Car_Id=1.

I everytime the user select the Car_Decription from the Drop Down List..I want the corresponding Make,Model to be displayed on the page in text boxes and diable them, so users cant change or write to it. I dont know how to do it.

Can someone please help. This the code i have till now.

<cfquery name=&quot;CarTypeDD&quot; datasource=&quot;CarMileage&quot;>
SELECT Car_Description
FROM Car_Info
ORDER BY Car_year DESC
</cfquery>

<html>
<head>
<title>Car Mileage System</title>
Choose a car:
<select name=&quot;CarType&quot;>
<cfoutput query=&quot;CarTypeDD&quot;>
<option value=&quot;#CarTypeDD.Car_Description#&quot;>
#CarTypeDD.Car_Description#
</option>
</cfoutput>
</select>
</p>
Make:
<input type=&quot;text&quot; name=&quot;textfield9&quot;>

Model:
<input type=&quot;text&quot; name=&quot;textfield10&quot;>

<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>
</form>
</body>
</html>

 
You need to submit the form every time a car is selected and then load the fields with the appropriate values. (If you don't want your users to edit the fields, then just print them on the screen as text rather then put them in a textbox.

Good Luck
 
Can you show me an example? or make changes to my code.
Thanks for the help.
 
The best way is to create some dynamic VBScript.

You will have to edit the field names but should at least get you started....

<CFQUERY datasource=&quot;XXXXXXXXX&quot; NAME=&quot;CarTypeDD&quot;>
SELECT Car_id, Car_Description, Car_Make, Car_Model, Car_Year
FROM Pubs.dbo.Car_Info
ORDER BY Car_Year
</cfquery>

Choose a car:
<select name=&quot;CarType&quot; onchange=&quot;GetDetails()&quot;>
<cfoutput query=&quot;CarTypeDD&quot;>
<option value=&quot;#CarTypeDD.Car_Description#&quot;>
#CarTypeDD.Car_Description#
</option>
</cfoutput>
</select>
</p>

<INPUT type=&quot;Text&quot; name=&quot;CarMake&quot; disabled>
<INPUT type=&quot;Text&quot; name=&quot;CarYear&quot; disabled>
<INPUT type=&quot;Text&quot; name=&quot;CarModel&quot; disabled>


<SCRIPT language=&quot;VBScript&quot;>

SUB GetDetails()

<CFOUTPUT query=&quot;CarTypeDD&quot;>
IF CarType.Value = &quot;#Car_Description#&quot; THEN
CarMake.Value = &quot;#Car_Make#&quot;
CarModel.Value = &quot;#Car_Model#&quot;
CarYear.Value = &quot;#Car_Year#&quot;
END IF
</cfoutput>

END SUB

</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top