Skip navigation
Currently Being Moderated

Simple Default value for drop down menu

May 11, 2012 1:42 PM

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

 
Replies
  • Currently Being Moderated
    May 12, 2012 6:40 AM   in reply to jamie61880

    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>

     
    |
    Mark as:
  • Currently Being Moderated
    May 14, 2012 1:06 PM   in reply to jamie61880

    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".

     
    |
    Mark as:
  • Currently Being Moderated
    May 15, 2012 12:27 AM   in reply to jamie61880

    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())#">

     
    |
    Mark as:
  • Currently Being Moderated
    May 15, 2012 10:56 AM   in reply to jamie61880

    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>

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points