View Full Version : Checkboxes and database

10-20-2008, 08:08 PM

Am dynamically adding checkboxes to my form...the number of checkboxes depend on the number of elements in my database

for($i=1;$i<=$a1;$i++) {
echo "<input type='checkbox' name='chkboxes' value=$i>";

Now, am using this function in the <head> section to check which checkboxes are checked...

function get_check_value() {

for (var i=1; i < document.chk.length; i++) {
if (document.applyform.chk[i].checked) {
value = document.applyform.chk[i].value;



here, instead of the alert, i need to insert into mysql...i tried using php here but it does not seem to work...what should i do?

10-21-2008, 10:32 AM
javascript is client side and you can't directly execute a database operation(which is purely sererside) by this. You'd need to use Ajax, if no form submit is required.

10-21-2008, 01:06 PM
ok...i get what you are saying...

could you explain more about how i can do it using ajax? i've never worked on it before...