hmm when I first looked at Sam's code, I didn't see he has a name for his
FORM, he probably needs to change "this_form" as "document.forms[0]",
assuming he has only one form in the page...

----Original Message Follows----
From: Vyas Vemu <[EMAIL PROTECTED]>

Please rewrite your function as follows:

<SCRIPT Language="Javascript">
function validate(this_form)
{
      if (this_form.gmrpeople.selectedIndex < 0)
      {
          alert("Please select a user");
          return false;
      }
     return true;
}
</SCRIPT>


This should work.
Good luck.

Vyas


-----Original Message-----
From: Sam Rose [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 07, 1999 2:30 AM
To: [EMAIL PROTECTED]
Subject: A bit of the list subject but ----Javascript


Hello, sorry this is off topic.

I was wondering if any one could help me.
I need to make sure that a select box has items highlighted when the
HTML page is submitted. I have tried this but it does not work, could
someone help me out please.

<script language="Javascript">

  function validate(this_form) {
       // required form values
           var User =
this_form.gmrpeople[this_form.gmrpeople.selectedIndex].value;
   //gmrpeople is the select box
  //begin validation
        if (!( User == "")) {
        return true;
       }
       else {
            msg = "\nYou need to highlight an option in the
selectbox:\n";
            alert(msg);
            return false;
      }
  }

</SCRIPT>

And with the FORM

<FORM onSubmit="return validate(this)" ACTION="/vdb/newlite"
METHOD="post">

If anyone could help I would be most appreciative.

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html



_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to