Limit of number of dropdowns selected

Discussion in 'Javascript' started by ll, Jun 7, 2006.

  1. ll

    ll Guest

    This script contains the check for a single drop down; however, I am
    needing to check to make sure that only one of my seven drop down boxes
    is selected - is there a way to assign a count variable (increment)
    whenever a drop down is selected and thus use that in the checking
    mechanism, or would there be a simpler way?

    Thanks


    >
    > =======================
    > <script language="JavaScript">
    > // last name
    >
    > function checkLastName (strng) {
    > var error = "";
    > if (strng == "") {
    > error = "Please enter your last name.\n\n";
    > }
    > return error;
    > }
    >
    > // department
    >
    > function checkDepartment (strng) {
    > var error = "";
    > if (strng == "") {
    > error = "Please enter your department.\n\n";
    > }
    >
    > return error;
    > }
    >
    > // valid selector from dropdown list
    >
    > function checkClassSession(choice) {
    > var error = "";
    > if (choice == 0) {
    > error = "Please choose a class session from the drop-down
    > list.\n\n";
    > }
    > return error;
    > }
    >
    >
    > <!-- Begin check form script -->
    > <!--
    > function checkWholeForm(theForm) {
    > var why = "";
    > why += checkLastName(theForm.last_name.value);
    > why += checkDepartment(theForm.department.value);
    > why += checkClassSession(value);
    > if (why != "") {
    > alert(why);
    > return false;
    > }
    > return true;
    > }
    > // -->
    > </script>
    >
    > ---------
    > here is the way it's called in the body:
    > <form name="theForm" method="post" onsubmit="return
    > checkWholeForm(this)"
    > action="http://www.domain.com/cgi-bin/genform.pl?">
    > ----------
    >
    > Thanks again,
    > Louis
    >
    >
    ll, Jun 7, 2006
    #1
    1. Advertising

  2. ll

    ll Guest

    ll wrote:
    > This script contains the check for a single drop down; however, I am
    > needing to check to make sure that only one of my seven drop down boxes
    > is selected - is there a way to assign a count variable (increment)
    > whenever a drop down is selected and thus use that in the checking
    > mechanism, or would there be a simpler way?
    >
    > Thanks
    >
    >
    > >
    > > =======================
    > > <script language="JavaScript">
    > > // last name
    > >
    > > function checkLastName (strng) {
    > > var error = "";
    > > if (strng == "") {
    > > error = "Please enter your last name.\n\n";
    > > }
    > > return error;
    > > }
    > >
    > > // department
    > >
    > > function checkDepartment (strng) {
    > > var error = "";
    > > if (strng == "") {
    > > error = "Please enter your department.\n\n";
    > > }
    > >
    > > return error;
    > > }
    > >
    > > // valid selector from dropdown list
    > >
    > > function checkClassSession(choice) {
    > > var error = "";
    > > if (choice == 0) {
    > > error = "Please choose a class session from the drop-down
    > > list.\n\n";
    > > }
    > > return error;
    > > }
    > >
    > >
    > > <!-- Begin check form script -->
    > > <!--
    > > function checkWholeForm(theForm) {
    > > var why = "";
    > > why += checkLastName(theForm.last_name.value);
    > > why += checkDepartment(theForm.department.value);
    > > why += checkClassSession(value);
    > > if (why != "") {
    > > alert(why);
    > > return false;
    > > }
    > > return true;
    > > }
    > > // -->
    > > </script>
    > >
    > > ---------
    > > here is the way it's called in the body:
    > > <form name="theForm" method="post" onsubmit="return
    > > checkWholeForm(this)"
    > > action="http://www.domain.com/cgi-bin/genform.pl?">
    > > ----------
    > >
    > > Thanks again,
    > > Louis
    > >
    > >
    ll, Jun 7, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KathyB
    Replies:
    6
    Views:
    568
    Todd Thompson
    Jun 27, 2003
  2. Paul

    DropDowns... another one.

    Paul, Jul 14, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    379
  3. Jason Shohet
    Replies:
    1
    Views:
    338
    Jose L Rodriguez
    Dec 11, 2003
  4. Replies:
    1
    Views:
    1,069
    Victor Bazarov
    Jun 28, 2005
  5. Doogie
    Replies:
    1
    Views:
    575
    ATR2000
    Sep 29, 2008
Loading...

Share This Page