Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

How to get the selected Checkbox Index or value in PHP/Javas

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

How to get the selected Checkbox Index or value in PHP/Javas

Postby stephenrodrics » Fri Aug 23, 2013 3:16 am

How to get the selected Checkbox Index or value in PHP/Javascript

Below is my UI table

the page where checkbox are created that is submitted to a Form
Attachments
image001.png
image001.png (7.13 KiB) Viewed 286 times
stephenrodrics
New php-forum User
New php-forum User
 
Posts: 54
Joined: Thu Mar 14, 2013 6:10 am

Re: How to get the selected Checkbox Index or value in PHP/J

Postby johnj » Fri Aug 23, 2013 5:29 am

something like this (i have not tested this example):
assuming the checkboxes have the name called "myinput" and class name as "sampleCheckbox"
Code: Select all
var checkedValue = '';
var inputElements = document.getElementsByTagName('myinput');
for(var i=0; inputElements[i]; i++){
      if(inputElements[i].className==="sampleCheckbox" && inputElements[i].checked)
     {
           checkedValue = inputElements[i].value;
           break;
      }
}
something like this...
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.