IndyB
09-11-2003, 10:32 AM
I'm trying to update a text field based on the selection made in a select list. Both the data from the select list and the resulting text field are stored in a db.
The select list is dynamically populated with the 'fullCat' values from the db. When the user makes their selection from the list, I need the text field to be automatically populated with the value that corresponds to the 'fullCat' value in the db. Basically, 'fullCat' is a long category name, and 'Category' is the abbreviated category name.
I need to do this without submitting the form b/c there is already info filled out on the form.
Any ideas?
This is what I'm trying so far, but I'm getting an "Object Expected" error:
<cfquery name="get_categories" datasource="#request.app.dsn#">
SELECT urlCat, fullCat
FROM tblCatPics
</cfquery>
<tr>
<td>Category Name:</td>
<td><select name="fullCat" required="yes" onChange="getValue(this)">
<option>Select</option>
<cfoutput query="get_categories">
<option value="#fullCat#">#fullCat#</option>
</cfoutput>
</select>
</td>
</tr>
<tr>
<td>Category Abreviated:</td>
<td><input type="text" readonly="yes" name="Category" value="" size="15"></td>
</tr>
<script language="JavaScript">
function getValue(otherElement) {
var fullCat = otherElement.form.fullCat.value;
alert = ('fullCat')
<cfoutput query="get_categories">
if( #fullCat# == fullCat){
alert = ('#urlCat#')
otherElement.form.Category.value = "#urlCat#";
}
</cfoutput>
}
</script>
The select list is dynamically populated with the 'fullCat' values from the db. When the user makes their selection from the list, I need the text field to be automatically populated with the value that corresponds to the 'fullCat' value in the db. Basically, 'fullCat' is a long category name, and 'Category' is the abbreviated category name.
I need to do this without submitting the form b/c there is already info filled out on the form.
Any ideas?
This is what I'm trying so far, but I'm getting an "Object Expected" error:
<cfquery name="get_categories" datasource="#request.app.dsn#">
SELECT urlCat, fullCat
FROM tblCatPics
</cfquery>
<tr>
<td>Category Name:</td>
<td><select name="fullCat" required="yes" onChange="getValue(this)">
<option>Select</option>
<cfoutput query="get_categories">
<option value="#fullCat#">#fullCat#</option>
</cfoutput>
</select>
</td>
</tr>
<tr>
<td>Category Abreviated:</td>
<td><input type="text" readonly="yes" name="Category" value="" size="15"></td>
</tr>
<script language="JavaScript">
function getValue(otherElement) {
var fullCat = otherElement.form.fullCat.value;
alert = ('fullCat')
<cfoutput query="get_categories">
if( #fullCat# == fullCat){
alert = ('#urlCat#')
otherElement.form.Category.value = "#urlCat#";
}
</cfoutput>
}
</script>