This site uses cookies from Google to deliver its services, to personalize ads and to analyze traffic. Information about your use of this site is shared with Google. By using this site, you agree to its use of cookies. Learn More

Jquery Php Checkbox Values to Php $_post Variables

Jquery Php Checkbox Values to Php $_post Variables Web-development (jquery) Jquery Php Checkbox Values to Php $_post Variables

jQuery PHP checkbox values to PHP $_POST variables
jQuery PHP checkbox values to PHP $_POST variables





<script type = "text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script> <script type = "text/javascript"> $(document).ready(function () { $('#submitBtn').click (function() { var selected = new Array(); $("input:checkbox[name=programming]:checked").each(function() { selected.push($(this).val()); }); var selectedString = selected.join(","); $.post("test.php", {selected: selected }, function(data){ $('.result').html(data); }); }); }); </script> <form name = "someForm" method = "post" action = "#"> <input type="checkbox" name="programming" value="Javascript" />Javascript<br /> <input type="checkbox" name="programming" value="Jquery" />Jquery<br/> <input type="checkbox" name="programming" value="Ajax" />Ajax<br /> <input type="checkbox" name="programming" value="Json" />Json<br/> <a href = "#" id = "submitBtn">Submit</a> </form> <div class = "result"></div> 
<?php $selected = $_POST['selected']; foreach ($selected as $value) { echo $value . " <br/>"; } ?> 

0 Response to "Jquery Php Checkbox Values to Php $_post Variables"

Posting Komentar

Contact

Nama

Email *

Pesan *