Web Analytics Made Easy -
StatCounter Syntax for function - CodingForum

Announcement

Collapse
No announcement yet.

Syntax for function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Syntax for function

    I'm using a validation code that changes an image when the form fails to pass validation. One of my form elements is drop down box with an initial value of "Please Select". I want the box to fail validation when its value is left as "Please Select". The code for the function is:

    function validateForm() {

    haveerrors = 0;
    (document.form1.slsStore.value=="Please Select")
    ? showImage("storeerror", "/images/storenumber.gif", true)
    : showImage("storeerror", "/images/blankimage.gif", false);

    return (!haveerrors);
    }

    ...what is the proper syntax for "document.form1.slsStore..."

  • #2
    I think that syntax looks ok... is it throwing an error?

    another method is to use:
    Code:
    document.form1.slsStore.value.match("Please Select")
    match() looks for an occurence of "Please Select" inside of slsStore.value, and returns true if it exists, and false otherwise.

    Are you getting some other errors? I've never seen showImage, but I imagine that you're trying to do something like this:


    Anyways, good luck with it.
    Sadiq.

    Comment


    • #3
      Fixed it with:

      document.form1.slsStore.selectedIndex == 0

      thanks for your help.

      Comment


      • #4
        That's the shortest solution. But if you will follow your original script, it should be modified to:

        (document.form1.slsStore.options[document.form1.slsStore.selectedIndex].text=="Please Select")
        Glenn
        vBulletin Mods That Rock!

        Comment

        Working...
        X