Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Checkboxes and database

    Hi,

    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;

    alert(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?

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,866
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    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.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •