简体   繁体   中英

Identify the checkbox that is checked, in a group of checkboxes

I have 2 checkboxes in a form and onclick of these, some php code needs to be executed and based on the result of the code, the checkbox is checked or unchecked.

So i have written onclick = document.formName.submit(); Now it is triggering the same page and i am able to write the code. I am not able to differentiate which checkbox is checked.

I don't want to use the procedure of:- calling javascript and then storing the value of the checkbox in a variable and making this variable as invisible.

I would like to write something like document.formName.submit('checkbox1'). So that i should be able to handle the value of this or i dont know.

Please suggest me an alternative method or better approach.

You can't do it correctly using either saving values in database or passing it as parameter. you have to store somewhere so that when page is get refreshed it must come to know which checkbox is checked earlier.

What exactly are you doing in the PHP code? Is it validating whether or not they are able to check that box? Sounds like you're making an extra unnecessary step here... If you could describe your scenario a little better I'm sure someone could point you to a more efficient way to accomplish this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM