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

  • SEARCH
  • Home
  • 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 8122841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:57:47+00:00 2026-06-06T05:57:47+00:00

I created the follwing table which gives the user option to uses check boxes

  • 0

I created the follwing table which gives the user option to uses check boxes to ehter the selection. I limited the number of selection to four, but its selecting more than 4 choices.

HTML:

<table width="100%" border="0">
    <tr>
        <th width="37%" height="19" align="center" bgcolor="#CCCCCC">
            <strong>Biological</strong>
        </th>
        <th width="37%" align="center" bgcolor="#CCCCCC">
            <strong>Psychological</strong>
        </th>
        <th width="37%" align="center" bgcolor="#CCCCCC">
            <strong>Social</strong>
        </th>
    </tr>
    <tr>
        <td>
            <input type="radio" name="Antidepressant" id="Antidepressant" value="Antidepressant" onclick="chkcontrol(1)" />
            <label for="Antidepressant"></label>Antidepressant</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td>
            <input type="radio" name="Antipsychotic oral" id="Antipsychotic oral" value="Antipsychotic oral" onclick="chkcontrol(2)" />
            <label for="Antipsychotic oral"></label>Antipsychotic oral</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td>
            <input type="radio" name="Antipsychotic_depot" id="Antipsychotic depot" value="Antipsychotic depot" onclick="chkcontrol(3)" />
            <label for="Antipsychotic depot"></label>Antipsychotic depot</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td>
            <input type="radio" name="Bblocker" id="B-blocker" value="B-blocker" onclick="chkcontrol(4)" />
            <label for="B-blocker"></label>B-blocker</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td>
            <input type="radio" name="Benzodiazepine" id="Benzodiazepine" value="Benzodiazepine" onclick="chkcontrol(5)" />
            <label for="Benzodiazepine"></label>Benzodiazepine</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td>
            <input type="radio" name="Mood_stabiliser" id="Mood stabiliser" value="Mood stabiliser" onclick="chkcontrol(6)" />
            <label for="Mood stabiliser"></label>Mood stabiliser</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td>
            <input type="radio" name="ECT" id="ECT" value="ECT" onclick="chkcontrol(7)" />
            <label for="ECT"></label>ECT</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td>
            <input type="radio" name="Otherbio" id="Other" value="Other" />
            <label for="Other"></label>Other</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
</table>

The script used to chec the number of selection:

function chkcontrol(j) {
    var total = 0;
    for (var i = 0; i < document.form1.ckb.length; i++) {
        if (document.form1.ckb[i].checked) {
            total = total + 1;
        }
        if (total > 4) {
            alert("Please Select only three")
            document.form1.ckb[j].checked = false;
            return false;
        }
    }
}

Here’s a screenshot:

enter image description here

  • 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-06-06T05:57:48+00:00Added an answer on June 6, 2026 at 5:57 am

    After a few minor corrections:

    <html>
    <head>
    <script type="text/javascript">
    function chkcontrol(j) {
        var total=0;
        for(var i=0; i < document.form1.ckb.length; i++){
            if(document.form1.ckb[i].checked){
                total =total +1;
            }
            if(total > 4){
                alert("Please Select only four!")
                document.form1.ckb[j].checked = false ;
                return false;
            }
        }
    }
    </script>
    
    </head>
    <body>
    <table width="100%" border="0">
        <form action="" id="form1" name="form1">
                <tr>
                  <th width="37%" height="19" align="center" bgcolor="#CCCCCC"><strong>Biological</strong></th>
                  <th width="37%" align="center" bgcolor="#CCCCCC"><strong> Psychological</strong></th>
                  <th width="37%" align="center" bgcolor="#CCCCCC"><strong> Social</strong></th>
                </tr>
                <tr>
                  <td><input type="radio" name="Antidepressant" id="ckb" value="Antidepressant" onclick="chkcontrol(0);" />
                    <label for="Antidepressant"></label>Antidepressant</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td><input type="radio" name="Antipsychotic oral" id="ckb" value="Antipsychotic oral" onclick="chkcontrol(1);" />
                    <label for="Antipsychotic oral"></label>Antipsychotic oral</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td><input type="radio" name="Antipsychotic_depot" id="ckb" value="Antipsychotic depot" onclick="chkcontrol(2);" />
                    <label for="Antipsychotic depot"></label>Antipsychotic depot</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td><input type="radio" name="Bblocker" id="ckb" value="B-blocker"  onclick="chkcontrol(3);"/>
                    <label for="B-blocker"></label>B-blocker</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td><input type="radio" name="Benzodiazepine" id="ckb" value="Benzodiazepine"  onclick="chkcontrol(4);"/>
                    <label for="Benzodiazepine"></label>Benzodiazepine</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td><input type="radio" name="Mood_stabiliser" id="ckb" value="Mood stabiliser"  onclick="chkcontrol(5);"/>
                    <label for="Mood stabiliser"></label>Mood stabiliser</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td><input type="radio" name="ECT" id="ckb" value="ECT"  onclick="chkcontrol(6);"/>
                    <label for="ECT"></label>ECT</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td><input type="radio" name="Otherbio" id="ckb" value="Other"  onclick="chkcontrol(7);"/>
                    <label for="Other"></label>
                    Other</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
            </form>
        </table>
    </body>
    </html>
    

    Still, it doesn’t make sense as the form is not submitting its content anywhere, but it’s a good POC.

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

Sidebar

Related Questions

Consider the following table which has the fields - id (int) and date_created (datetime):
I have the following code which creates a new table. var html = '<table>';
I have following Table with records for ActivityLog: ID, UserId, Category, Created 1 11
I have the following table <thead> <tr> <th>Account ID</th> <th>Code</th> <th>Date Created</th> <th>Date Expires</th>
I created the following script to query a table and return the first 30
I have a computed column created with the following line: alter table tbPedidos add
I am using AdventureWorks2012 database. I created the following index on Sales.SalesOrderHeader table create
I have created a table with the following columns: ObservationId, FirstCreatedDate, description, ... ...
I have created a table with the following structure- $sql = CREATE TABLE followers
Given the following table structure: CREATE TABLE user ( uid INT(11) auto_increment, name VARCHAR(200),

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.