Hi,
I have two select boxes that have the id attribute associated with them.
When my page is first called, they have pre-selected data are the select boxes already have options.
The second select box is dependent on the first.
When the first box is changed, a javascript function is invoked and another template to process a value is called.
function setVendors(servicetypeid){
<cfoutput>
backstage.location.href="bs_loadvendors.cfm?servicetypeid=" + servicetypeid;
</cfoutput>
}
Here's my logic from the (.cfm) file in case you need it.
This processing holds the values that I want fed back into my second select box. Since the second select box already has values, I want those overwritten and replaced with my new values from this page.
The above is as far as I got. I’m able to see the new value pre-select after the first select box is changed, but there are still the initial values in my select box.
What am I doing wrong?
Thanks in advance for any help you can provide.
Soho34
I have two select boxes that have the id attribute associated with them.
Code:
<cfoutput>
<form action="" id="serviceview" name="serviceview" method="post">
<select id="servicetype" name="servicetype" onchange="setVendors(this.value);">
<cfloop query="gettypes">
<option onchange="" value="#gettypes.servicetypesid#" <cfif #gettypes.servicetypesid# eq #oneservice.servicetypeid#>selected</cfif>>
#gettypes.description#
</option>
</cfloop>
</select>
<select id="vendorname" name="vendorname">
<cfloop query="getvendors">
<option value="#getvendors.vendorid#" <cfif #getvendors.vendorid# eq #oneservice.vendorid#>selected</cfif>>
#getvendors.name#
</option>
</cfloop>
</select>
</form>
</cfoutput>
When my page is first called, they have pre-selected data are the select boxes already have options.
The second select box is dependent on the first.
When the first box is changed, a javascript function is invoked and another template to process a value is called.
function setVendors(servicetypeid){
<cfoutput>
backstage.location.href="bs_loadvendors.cfm?servicetypeid=" + servicetypeid;
</cfoutput>
}
Here's my logic from the (.cfm) file in case you need it.
Code:
<body>
<cfparam name="url.servicetypeid" default="0">
<!--- Update status window. --->
<cfoutput>
<p>Servicetypeid supplied: ‘#url.servicetypeid#’ (#val(url.servicetypeid)#)</p>
</cfoutput>
<cfif val(url.servicetypeid)>
<cfquery name="getServiceVendors" datasource="#request.dsn#">
SELECT
st.servicetypesid,
vt.vendorid,
v.name
FROM
servicetypes st left join vendortypes vt
on st.servicetypesid = vt.servicetypeid left join
vendors v on vt.vendorid = v.vendorid
WHERE
st.servicetypesid = #url.servicetypeid#
</cfquery>
<cfset count=1>
<cfoutput query="getServiceVendors">
<cfloop query="getServiceVendors">
<script>
parent.serviceview.vendorname.options[#count#].text = "#name#";
parent.serviceview.vendorname.options[#count#].value = "#vendorid#";
</script>
<cfset count=count+1>
</cfloop>
</cfoutput>
</body>
This processing holds the values that I want fed back into my second select box. Since the second select box already has values, I want those overwritten and replaced with my new values from this page.
The above is as far as I got. I’m able to see the new value pre-select after the first select box is changed, but there are still the initial values in my select box.
What am I doing wrong?
Thanks in advance for any help you can provide.
Soho34