Results 1 to 3 of 3

Thread: A JScript action within a form

  1. #1
    Join Date
    Jan 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default A JScript action within a form

    I have a simple HTML form, that is asking the user for details on events.
    When a certain event is selected in a checkbox, the user then has to select some otherinformation from a drop down box.

    I have this piece of code, and it doesnt seem to be working:

    if (theform.weddings_cbox.value=="Information please"&&theform.eventMonth.options[0].selected){
    alert("Please ensure that you select your preferred month and year for your wedding day.");
    theform.eventMonth.focus();
    return false;
    }

    What Im asking it to do, is check if the checkbox has been selected but if the user hasnt followed the command to selct the month or year then that alert comes up.

    Whats happening, is that alert pops up regardless of whether the checkbox has been selected or not.

    Can anybody take a look for me.

    Lee

  2. #2
    Join Date
    Jun 2006
    Posts
    182
    Thanks
    0
    Thanked 14 Times in 14 Posts

    Default

    Try that:
    Code:
    if (theform.weddings_cbox.checked && theform.eventMonth.selectedIndex == 0) {
        alert("Please ensure that you select your preferred month and year for your wedding day.");
        theform.eventMonth.focus();
        return false;
    }

  3. #3
    Join Date
    Jan 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you very much, that did the trick

    cheers

    Lee

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
  •