Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 562645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:34:35+00:00 2026-05-13T12:34:35+00:00

I have five combo boxes. Each one has a different name, but the possible

  • 0

I have five combo boxes. Each one has a different name, but the possible values for each are the same: 1-5. I would like to use Javascript to validate two things:

  1. that each value is selected only once. For example, if the value of “cboCircle” is “1” then the value of “cboSquiggle” cannot be 1, and so on.

  2. that each selected value is used (i.e. that 1, 2, 3, 4, and 5 have all been chosen.)

Essentially, these values are supposed to act as a ranking system for the combo boxes, in a rough sort of way…

Anyone know how I might be able to accomplish this?

NOTE: I’m new to JS. Thanks!

<head>
<script language="javascript">
function submitSurvey(recID)
{
    var msg = "";

    if ( (document.form.cboCircle.value=="0") || 

(document.form.cboSquiggle.value=="0") ||
 (document.form.cboRectangle.value=="0") || 
(document.form.cboSquare.value=="0") || 
(document.form.cboTriangle.value=="0") )

    {   
        msg += "Please select a value for each combo box.\n";
    }   

    if (msg == "")
    {
        document.getElementById("txtRecID").value = recID;
        form.action = "post.asp";
        form.submit();
    }
    else
    {
        alert (msg);
    }   
}
</script>
</head>

<body>
<form name="form" id="form" method="post">
    <table>
    <table width="99%">
        <tr>
            <td width="29%" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
                <p align="center"><img name="circle" src="../images/circle.jpg" width="158" height="146" alt=""></p>
            </td>
            <td width="35%" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
                <p align="center"><img name="squiggle" src="../images/squiggle.jpg" width="204" height="155" alt=""></p>
            </td>
            <td width="36%" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
                <p align="center"><img name="rectangle" src="../images/rectangle.jpg" width="216" height="122" alt=""></p>
            </td>
        </tr>
        <tr>
            <td bordercolor="#FFFFFF" bgcolor="#FFFFFF">
                <p align="center">
                <select name="cboCircle" id="cboCircle">
                    <%
                    If RS("shapePrimary") = "Circle" Then   
                    %>
                        <option value="1" selected>1</option>   
                    <%
                    Else
                    %>
                        <option value="0"></option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                    <%
                    End If          
                    %>
                </select>
                </p>
            </td>   

            <td bordercolor="#FFFFFF" bgcolor="#FFFFFF">
                <p align="center">
                <select name="cboSquiggle" id="cboSquiggle">
                    <%
                    If RS("shapePrimary") = "Squiggle" Then 
                    %>
                        <option value="1" selected>1</option>   
                    <%
                    Else
                    %>
                        <option value="0"></option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                    <%
                    End If          
                    %>
                </select>
                </p>    
            </td>

            <td bordercolor="#FFFFFF" bgcolor="#FFFFFF">
                <p align="center">
                <select name="cboRectangle" id="cboRectangle">
                    <%
                    If RS("shapePrimary") = "Rectangle" Then    
                    %>
                        <option value="1" selected>1</option>   
                    <%
                    Else
                    %>
                        <option value="0"></option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                    <%
                    End If          
                    %>
                </select>
                </p>
            </td>
        </tr>
        <tr>
            <td bordercolor="#FFFFFF" bgcolor="#FFFFFF">
                <p align="center"><img name="square" src="../images/square.jpg" width="141" height="143" alt=""></p>
            </td>
            <td bordercolor="#FFFFFF" bgcolor="#FFFFFF">
                <p align="center"><img src="../images/triangle.jpg" alt="" name="triangle" width="226" height="167" id="triangle2"></p>
            </td>
            <td bordercolor="#FFFFFF" bgcolor="#FFFFFF">&nbsp;</td>
        </tr>
        <tr>
            <td bordercolor="#FFFFFF" bgcolor="#FFFFFF">
                <p align="center">
                <select name="cboSquare" id="cboSquare">
                    <%
                    If RS("shapePrimary") = "Square" Then   
                    %>
                        <option value="1" selected>1</option>   
                    <%
                    Else
                    %>
                        <option value="0"></option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                    <%
                    End If          
                    %>
                </select>
                </p>
            </td>
            <td bordercolor="#FFFFFF" bgcolor="#FFFFFF">
                <p align="center">
                <select name="cboTriangle" id="cboTriangle">
                    <%
                    If RS("shapePrimary") = "Triangle" Then 
                    %>
                        <option value="1" selected>1</option>   
                    <%
                    Else
                    %>
                        <option value="0"></option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                    <%
                    End If          
                    %>
                </select>
                </p>
            </td>
            <td bordercolor="#FFFFFF" bgcolor="#FFFFFF">&nbsp;</td>
        </tr>
    </table>
    <p>&nbsp;</p>
    <table width="99%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" class="WebApps">

        <tr>
            <td width="100%">
            <p align="left">
            <input name="btnSubmit" type="button" class="button" id="btnSubmit" value="Submit Survey" onClick="submitSurvey('<%= RS("recID")%>');">
            </p>
            </td>
        </tr>
    </table>
</form>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:34:35+00:00Added an answer on May 13, 2026 at 12:34 pm
    function checkThem(){ //returns true or false - your caller can do the alert/submit
      var cbNames = ["cboCircle","cboSquiggle","cboRectangle","cboSquare","cboTriangle"];
      var valsTaken = [];
      for (var i = 0; i < cbNames.length; i++) {
        var idx = document.form[cbNames[i]].selectedIndex;
        if (idx == 0 || valsTaken[idx]) return false; //not selected or already found
        valsTaken[idx] = true;
      }
      return true; //if we got to here, all is right with the world....
    }
    

    I’m sure there are other (possibly simpler) ways to do this, but the above should work…
    All it’s doing is keeping a record of whether something has already been selected, in valsTaken and returning false if it’s already been taken or is 0

    Edit: original poster wants separate messages depending on selected/not selected. Try this:

    function checkThem(){ //returns {unselected: i} or {selectedTwice: idx}
      var cbNames = ["cboCircle","cboSquiggle","cboRectangle","cboSquare","cboTriangle"];
      var valsTaken = [];
      for (var i = 0; i < cbNames.length; i++) {
        var idx = document.form[cbNames[i]].selectedIndex;
        if (idx == 0) return { unselected: cbNames[i] };
        if (valsTaken[idx]) return {  selectedTwice: idx }; 
        valsTaken[idx] = true;
      }
      return {ok: true}; //if we got to here, all is right with the world....
    }
    
    var rsltObj = checkThem();
    if (rsltObj.unselected) {
      alert(rsltObj.unselected + " not selected");
    } else if (rsltObj.selectedTwice) {
      alert(rsltObj.selectedTwice + " has been selected twice");
    } else {
      alert("Ok");
    }
    

    Please note that this second example is probably not the best code – I’ve just done this as quickly as I could

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of five boolean values. If more than one of these
Assume you have five products, and all of them use one or more of
I have a solution consisting of five projects, each of which compile to separate
I have five tables: models : id, name, specification models_networks : id, model_id, network_id
I have five values, A, B, C, D and E. Given the constraint A
I have five movie clips in my library. I want to load each to
I have five fields for number input, and each of these fields must be
What are the key differences between Flash and Flex? I have over five years
I have the following five tables: ISP Product Connection AddOn AddOn/Product (pivot table for
I have a Div with five float divs inside: var div=document.createElement(div); div.className=cssDivNino; var divFolio=document.createElement(div);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.