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 6811665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:21:18+00:00 2026-05-26T20:21:18+00:00

I have looked all over for an answer and hope someone here can help.

  • 0

I have looked all over for an answer and hope someone here can help. I have a script that runs when you check a check box from a group of checkboxes. The checkboxes are assigned a value of “customer id”

<input type="checkbox" name="inv_add[]" onclick="setcid(\''.$result['cid'].'\')" value='.$result['id'].'/>

the point of the javascript is to assign a value to a hidden field telling the next page what the customer id is for all of checked boxes.

If you the user checks a box that is assigned to a different customer (therefore does not belong in the group) i want to alert the user and then uncheck the last box checked.
I can get all the way to the alert but can not uncheck the box the user just checked.

function setcid(cid) {

if (window.set_x === undefined) {
    sethidden = document.getElementById('cid');
    sethidden.value = cid;
    set_x = cid;
    alert ("finished setting x");

    }

    else if (cid !== set_x){
            alert ("You are trying to add two different companies to the same invoice");
                           /*Uncheck the box just checked by user*/
            }

        else {
            alert("they are the same");
                           /*no modification required*/
            }

}
  • 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-26T20:21:19+00:00Added an answer on May 26, 2026 at 8:21 pm

    You can pass the this object as you call the function:

    http://jsfiddle.net/msV24/

    HTML

    <input type="checkbox" name="inv_add[]" onclick="setcid(\''.$result['cid'].'\',this)" value='.$result['id'].'/>
    

    javascript

    function setcid(cid, sender) {
    
    ...
    
        else if (cid !== set_x){
            alert ("You are trying to add two different companies to the same invoice");
                           sender.checked = false;
            }
    
        else {
            alert("they are the same");
                           /*no modification required*/
            }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked all over but can't find an answer to this... Quite simply
I have looked all over the web and I can not find the information
I have looked all over the internet to find an answer to my problem
I have looked all over stack overflow, for the answer to this question, and
I have looked all over the internet and haven't found my answer. Whenever one
I have looked all over the internet for an answer to my question to
I have looked all over the internet. Can anyone point me to some resources
I've looked all over for an answer to this, and I can't find any
I have looked all of the place for this and I can't seem to
I have looked over the Repository pattern and I recognized some ideas that I

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.