SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Apr 2000
    Location
    Milwaukee, WI 53189
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've never tried this before, but is there a way to validate drop down boxes?

    my drop down consists of.

    Example:
    Hiring Source: [Select Hiring Source] <----drop down list

    Others in the list include
    temp agency, direct, newspaper, magazine.

    For some reason most people are not doing the drop down list so the initial value "Select Hiring Source" comes through when the form is posted... I want it to just validate that value so it can't be left in the default position. Any help would be appreciated...

    hope I didn't confuse anyone..

    Jeremy

  2. #2
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    First you have to find the selected index and then you can get the value from it.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">code/font><HR><pre>
    document.form.dropbox.options[document.form.dropbox.selectedIndex].value
    [/code]
    Or you can just use the Selected index
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">code/font><HR><pre>
    if document.form.dropbox.selectedIndex = 0
    Alert ("Choose a Hiring source!");
    [/code]


    ------------------
    Wayne Luke
    WR Moderator
    Internet Media Provider

  3. #3
    SitePoint Member
    Join Date
    Apr 2000
    Location
    Milwaukee, WI 53189
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I actually didn't want the first selection to be able to be chosen..

    I want them to get an error if that is left in the default position

  4. #4
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    That is why the second code snippet will create an Alert box telling them to choose a hire source if the value is zero.

    ------------------
    Wayne Luke
    WR Moderator
    Internet Media Provider

  5. #5
    SitePoint Member
    Join Date
    Apr 2000
    Location
    Milwaukee, WI 53189
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is this done in ASP or java?

    sorry.. I'm not really a programmer...

  6. #6
    SitePoint Enthusiast MAC's Avatar
    Join Date
    Feb 2000
    Location
    Somewhere on the heart of Dixie
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is done in Javascript.

    An execellent Javascript tutorial can be found at:
    http://hotwired.lycos.com/webmonkey/...tutorial1.html


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •