Question
problem in drop down
I am trying to do a query which will be based as :
schoolID s the PK
catID as reference to schools table.
CATid of categories table
Now i am trying to do like this:
i want i should select the category from drop, menu and name should appear in the dependent dropdown.
but due to some mine mistake i am in problem?
here is my complete code,:
<SCRIPT type="text/javascript" language="JavaScript1.2">
var arrLocations = new Array();
<cfoutput query="alldropdowns">
arrLocations[#alldropdowns.CurrentRow# - 1] =
new property(#alldropdowns.schoolid#,#alldropdowns.catid#,"#alldropdowns.campcategory#");
</cfoutput>
function property(sub1,ptype_Id,property_type_name){
this.sub1 = catid;
this.ptype_Id = catid;
this.property_type_name = campcategory;
}
function onChangeProperty(propertySelect,thisForm){
thisForm.elements["property"].length = 0;
for (var iii = 0; iii < arrLocations.length; iii++) {
if (propertySelect.value == arrLocations[iii].sub1) {
var newOption = new Option(arrLocations[iii].property_type_name,arrLocations[iii].ptype_Id);
thisForm.elements["property"].options[thisForm.elements["property"].length] = newOption;
}
}
if (thisForm.elements["property"].length == 0){
if (thisForm.elements['subdivision'].value == -1){
var newOption = new Option("Select Subdivision First!",-1);
}
else{
var newOption = new Option("N/A",-1);
}
thisForm.elements["property"].options[0] = newOption;
}
thisForm.elements["property"].options[0].selected = true;
}
</SCRIPT>
<tr>
<td class="b_settings"><p>Subdivision:</p></td>
<td><cfselect name="subdivision" size="1" class="b_settings"
onChange="onChangeProperty(this, this.form);" required="yes">
<option value="-1" selected="selected">Select Subdivision...</option>
<cfoutput query="Newcategory">
<option value="#catid#">#campcategory#</option>
</cfoutput> </cfselect>
<span class="startcolor">*</span> </td>
</tr>
<tr>
<td class="b_settings"><p>Property Type:</p></td>
<td><cfselect name="property" size="1" class="b_settings" required="yes">
<option value="-1" selected="selected">Select a Subdivision First!</option>
</cfselect>
<span class="startcolor">*</span> </td>
</tr>
The query which is deriving all these are:
<cffunction access="public" returntype="query" name="Combined">
<cfquery name="getLocal" datasource="#request.dsn#">
SELECT school_camps.catID, school_camps.schoolID, school_camps.campName, tblcategories.catID,
tblcategories.campcategory
FROM school_camps INNER JOIN tblcategories ON school_camps.catID = tblcategories.catID
ORDER BY campName asc
</cfquery>
<cfreturn getLocal>
</cffunction>
calling the CFC as:
<cfinvoke
component="EcoLife.admin.CFC.users"
method="Combined"
returnvariable="allDropdowns"/>
<cfinvoke
component="EcoLife.admin.CFC.users"
method="getCategory"
returnvariable="Newcategory"/>
Can anybody guide me please, what doing wrong here?
schoolID s the PK
catID as reference to schools table.
CATid of categories table
Now i am trying to do like this:
i want i should select the category from drop, menu and name should appear in the dependent dropdown.
but due to some mine mistake i am in problem?
here is my complete code,:
<SCRIPT type="text/javascript" language="JavaScript1.2">
var arrLocations = new Array();
<cfoutput query="alldropdowns">
arrLocations[#alldropdowns.CurrentRow# - 1] =
new property(#alldropdowns.schoolid#,#alldropdowns.catid#,"#alldropdowns.campcategory#");
</cfoutput>
function property(sub1,ptype_Id,property_type_name){
this.sub1 = catid;
this.ptype_Id = catid;
this.property_type_name = campcategory;
}
function onChangeProperty(propertySelect,thisForm){
thisForm.elements["property"].length = 0;
for (var iii = 0; iii < arrLocations.length; iii++) {
if (propertySelect.value == arrLocations[iii].sub1) {
var newOption = new Option(arrLocations[iii].property_type_name,arrLocations[iii].ptype_Id);
thisForm.elements["property"].options[thisForm.elements["property"].length] = newOption;
}
}
if (thisForm.elements["property"].length == 0){
if (thisForm.elements['subdivision'].value == -1){
var newOption = new Option("Select Subdivision First!",-1);
}
else{
var newOption = new Option("N/A",-1);
}
thisForm.elements["property"].options[0] = newOption;
}
thisForm.elements["property"].options[0].selected = true;
}
</SCRIPT>
<tr>
<td class="b_settings"><p>Subdivision:</p></td>
<td><cfselect name="subdivision" size="1" class="b_settings"
onChange="onChangeProperty(this, this.form);" required="yes">
<option value="-1" selected="selected">Select Subdivision...</option>
<cfoutput query="Newcategory">
<option value="#catid#">#campcategory#</option>
</cfoutput> </cfselect>
<span class="startcolor">*</span> </td>
</tr>
<tr>
<td class="b_settings"><p>Property Type:</p></td>
<td><cfselect name="property" size="1" class="b_settings" required="yes">
<option value="-1" selected="selected">Select a Subdivision First!</option>
</cfselect>
<span class="startcolor">*</span> </td>
</tr>
The query which is deriving all these are:
<cffunction access="public" returntype="query" name="Combined">
<cfquery name="getLocal" datasource="#request.dsn#">
SELECT school_camps.catID, school_camps.schoolID, school_camps.campName, tblcategories.catID,
tblcategories.campcategory
FROM school_camps INNER JOIN tblcategories ON school_camps.catID = tblcategories.catID
ORDER BY campName asc
</cfquery>
<cfreturn getLocal>
</cffunction>
calling the CFC as:
<cfinvoke
component="EcoLife.admin.CFC.users"
method="Combined"
returnvariable="allDropdowns"/>
<cfinvoke
component="EcoLife.admin.CFC.users"
method="getCategory"
returnvariable="Newcategory"/>
Can anybody guide me please, what doing wrong here?
