javascript - Show/Display the checked checkbox value using PHP or JS -


i thought if possible done php or javascript:

let's have 2 checkboxes:

<li><input type="checkbox" checked="checked" name="tuesday" value="111"/> tueday</li> <li><input type="checkbox" name="wednesday" value="112"/> wednesday</li>  

i want see value of checked="checked" 111 after page loaded.

how can achieve this? if possible in php , javascript, have both methods. thank you!

window.addeventlistener('load', function(){     var ch = document.getelementsbyname('tuesday')[0];     if(ch.checked)         // use ch.value }); 

or if want display checked values:

window.addeventlistener('load', function(){     var checkedvalues= [];     var chs = document.getelementsbytagname('input');     for(var = 0; < chs.length; i++)         if(chs[i].type.tolowercase() === 'checkbox' && chs[i].checked)             checkedvalues.push(chs[i].value);     // use checkedvalues }); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -