Skip to main content
Known Participant
May 17, 2013
Question

onchange

  • May 17, 2013
  • 1 reply
  • 519 views

Hi,

The second dropbox is displayed when location eq 5 is selected from the first drop box.  When i select the value from second dropbox, i want the value from the first drop box stays the same as location eq 5, and results need to refreseh to reflect with the select from the second box.  Can you pls help?- thx

<cfoutput>

<cfform name="myform" action="" method="post">

Location:

<select name="location" onchange="this.form.submit();">

<cfloop query="variables.qlocations" >

<option value="#id#" <cfif isDefined('form.location')><cfif form.location eq "#id#">selected</cfif></cfif>>#location#</option>

</cfloop>

</select>

<cfif form.location eq 5>

<select name="action" onchange="this.form.submit();">

<cfloop query="variables.qAction" >

<option value="#id#" <cfif isDefined('form.action')><cfif form.action eq "#id#">selected</cfif></cfif>>#action#</option>

</cfloop>

</select>

</cfif>

</cfform>

<!---display results here--->

....

<!---end display--->

</cfoutput>

This topic has been closed for replies.

1 reply

WolfShade
Legend
May 20, 2013

<cfparam name="form.location" default="">

...

<select name="location" id="location" onchange="this.form.submit();">

  <cfloop query="qlocations">

  <option value="#id#"<cfif form.location eq 5> selected="selected"</cfif>>#location#</option>

  </cfloop>

</select>

Your query loop cannot properly select the selected value because (if you look at the source code) you are comparing it so that EVERY option will be "selected" (if #id# = #id#.. everything equals itself.)

^_^