Skip to main content
Known Participant
September 29, 2008
Question

Creating dynamic pulldown

  • September 29, 2008
  • 2 replies
  • 262 views
I use the following code to create a dynamic pulldown list :

<select name="buyerSite" style="width:160px;">
<option selected value="0"><< -- Select One -- >></option>
<cfoutput query="qryGet_Site">
<option value="#qryGet_Site.buyersite#">#qryGet_Site.buyersite#</option>
</cfoutput>
</select>

It seems to work when I make a selection from the pulldown. But I am a little confused about the option selected value = "0" statement. When the form is first displayed, << -- Select One -->> is displayed in the pulldown window. If I decide not to make a selection, is the value "0" being passed ?

In my javascriptt edit, I have if (formName.buyerSite.selectedIndex.value == "0".....alert(messese)...etc.,
but nothing is displayed and the form processes.

I tried "0" and 0 and the javascript does not work. What am I doing wrong ? I just need to validate if a pulldown option was selected or not.

Thanks
    This topic has been closed for replies.

    2 replies

    September 29, 2008
    You don't want the form to submit if the option "0" has been selected. If the form IS submitting, then your problem is with the JavaScript, not Coldfusion.

    Have you looked into using "return false". You may also want to try posting on a forum more focused on JavaScript.
    Inspiring
    September 29, 2008
    When are you callling your js?