Skip to main content
Known Participant
November 5, 2010
Question

make the drop down option to remain at the option which is just selected a while ago

  • November 5, 2010
  • 1 reply
  • 531 views

After the option is selected and the submit button is clicked, the drop down option do not stay (will change to another option).

How to make the drop down option to remain at the option which is just selected a while ago?

<FORM ACTION="report.cfm" METHOD="POST"  name="ChooseType">
<table width = "930px" border = "0" cellspacing = "2" cellpadding="2" style = "border-bottom-style: solid;">
<tr>
<td width= "450px">
<span class = "TitleHeader" nowrap><cfmodule template="/GetPhrase.cfm" Phrase_ID="5303" ></span>
</td>
<td align= "left" valign="top">
<B><cfmodule template="/GetPhrase.cfm" Phrase_ID="5305" ></B>
<br>
<SELECT name ="frmCriteria">
<OPTION VALUE="full"
<CFIF Variables.displayCriteria EQ "between 1 and 100">
selected
</cfif>
>
<cfmodule template="/GetPhrase.cfm" Phrase_ID="5307" >
</option> <OPTION VALUE="average"
<CFIF Variables.displayCriteria EQ #mark#>
selected
</cfif>
>
<cfmodule template="/GetPhrase.cfm" Phrase_ID="5308" >
</option> <OPTION VALUE="passed"
<CFIF Variables.displayCriteria GT #mark#>
selected
</cfif>
>
<cfmodule template="/GetPhrase.cfm" Phrase_ID="7001" >
</option>
</SELECT>
</td>
<td valign="middle" align="bottom"></td>
<input type = "submit" name = "submit" value = Submit>
</tr>
</table>
</FORM>
This topic has been closed for replies.

1 reply

Owainnorth
Inspiring
November 6, 2010

The basic concept you've got is correct as far as I can see, but obviously there's other code in there affecting it. I've knocked you up a simple standalone working model, try adapting this bit by bit until you have your working example.

<cfparam name="form.MyVal" default="" />

<form method="post">

    <select name="MyVal">
        <option value="1" <cfif form.MyVal EQ 1 >selected</cfif>>one</option>
        <option value="2" <cfif form.MyVal EQ 2 >selected</cfif>>two</option>
        <option value="3" <cfif form.MyVal EQ 3 >selected</cfif>>three</option>
        <option value="4" <cfif form.MyVal EQ 4 >selected</cfif>>four</option>
        <option value="5" <cfif form.MyVal EQ 5 >selected</cfif>>five</option>
    </select>

    <input type="submit" />

</form>