• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Simple Default value for drop down menu

Engaged ,
May 11, 2012 May 11, 2012

Copy link to clipboard

Copied

Does anyone know why this would be happening?

      I have a drop down menu on my Quality page for PDF_Creation_Doc_Control_Approval_Initials (I’ll shorten this to Doc Initials so you know what I’m talking about). Right now it is defaulted to be blank if nothing has been chosen for it yet. If initials are chosen, the initials will display when the page is loaded. The problem I’m having is that I want the “None” option to display as the default if the SW_Model_Only is 1.  I’m just trying to get “None” to be the default for these. The code below does work if I hit the refresh button, but it does not work when I just click on the Quality link. Why would this be? How do I fix it? Below is the code for this drop down on the Quality Page. I added this If Statement:

<cfif SW_Model_Only Is 1>

<option value="None"></option>

<cfelse>

<option value=""></option>

</cfif>

     The option value="" was already there.

<cfset PDFCreationDocControlInitials = DocumentationSearch.PDF_Creation_Doc_Control_Initials>

<td align="center">

<cfif Quality_Mgr_Initials Is Not "" and Quality_Mgr_Initials EQ cookie.UserInitials<!--- and SW_Model_Only Is 0 --->>

<select name="PDF_Creation_Doc_Control_Approval_Initials#ItemID#" id="PDF_Creation_Doc_Control_Approval_Initials#ItemID#">

<cfif SW_Model_Only Is 1>

<option value="None"></option>

<cfelse>

<option value=""></option>

</cfif>

<cfloop query="ShowInitials">

<option value="#Initials#"

<cfif #Initials# EQ PDFCreationDocControlInitials>selected</cfif>>#Initials#</option>

</cfloop>

</select>

<cfelse>

 

</cfif>

  </td>

Thanks for your help.

Andy

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 12, 2012 May 12, 2012

Copy link to clipboard

Copied

Couldn't it be simplified to something like this?

<cfset optionDefault = "none">

<cfif SW_Model_Only NEQ 1>

    <cfset optionDefault = "">

</cfif>

<option value="#optionDefault#"></option>

<cfloop query="ShowInitials">

<option></option>

</cfloop>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 14, 2012 May 14, 2012

Copy link to clipboard

Copied

BKBK,

    No, this did not do anything. Any other ideas?

Andy

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 14, 2012 May 14, 2012

Copy link to clipboard

Copied

jamie61880 wrote:

BKBK,

    No, this did not do anything. Any other ideas?

Then I should ask you to clarify what you mean by a "click on the Quality link".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 14, 2012 May 14, 2012

Copy link to clipboard

Copied

There is a link that I have called "Quality Items". There are 2 ways to get the page updated. Either click the Refresh button, or click on this link. Clicking on the link does not allow "None" to display in the drop down menu. But if I was on this Quality page already and updated my code, and clicked the Refresh button, it puts "None" into the drop down as the default. Why would it work with clicking the Refresh button, but not clicking on the link?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 15, 2012 May 15, 2012

Copy link to clipboard

Copied

jamie61880 wrote:

There is a link that I have called "Quality Items". There are 2 ways to get the page updated. Either click the Refresh button, or click on this link. Clicking on the link does not allow "None" to display in the drop down menu. But if I was on this Quality page already and updated my code, and clicked the Refresh button, it puts "None" into the drop down as the default. Why would it work with clicking the Refresh button, but not clicking on the link?

It could be that, clicking on the link returns a cached copy of the page. To prevent caching, add the following headers at the top of the page:

<cfheader name="cache-control" value="no-cache,no-store,must-revalidate">

<cfheader name="pragma" value="no-cache">

<cfheader name="expires" value="#getHttpTimeString(now())#">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 15, 2012 May 15, 2012

Copy link to clipboard

Copied

BKBK,

    I put this code at the top of the page and the drop down does not have the "None" being the default at all now. So this might have answered the caching thing, but I still don't know how to make "None" be the default when the page loads. How do you make a word in a drop down menu be the default when the drop down menu is being populated dynamically from a database?

Andy

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 15, 2012 May 15, 2012

Copy link to clipboard

Copied

LATEST

By default, the first option is the one selected in a drop-down. As I said, something like this should work:

<cfset optionDefault = "none">

<cfif SW_Model_Only NEQ 1>

    <cfset optionDefault = "">

</cfif>

<cfoutput>

<select name="PDF_Creation_Doc_Control_Approval_Initials#ItemID#" id="PDF_Creation_Doc_Control_Approval_Initials#ItemID#">

<option value="#optionDefault#">#optionDefault#</option>

<cfloop query="ShowInitials">

<option value="#initials#">#initials#</option>

</cfloop>

</select>

</cfoutput>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation