#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    3
    Rep Power
    0

    Checkbox array submit through ajax


    i have some checkbox options. I want to selected checkbox value pass through url in another ajax loading page. just need the selected value pass in another page through ("#div").load("page_name.php?value=checkbox[]"); can anyone help me??
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    101
    Rep Power
    27
    If you use serialize() on the form that contains the checkboxes, then all the ones that are checked will be added to the resulting parameter string. So you could do something like
    Code:
    $("#div").load("page_name.php?"+$("#the_form").serialize());

    Comments on this post

    • mayakanon agrees : Thanks a lot
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    3
    Rep Power
    0

    Checkbox array submit through ajax


    Thanks for your help. I can retrieve the value one by one calling $_GET["Name"] parameter. Can i retrieve all value through array[] and how to call this array value in PHP?
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    3
    Rep Power
    0
    Thanks for your help. I can retrieve the value one by one calling $_GET["Name"] parameter. Can i retrieve all value through array[] and how to call this array value in PHP?
  8. #5
  9. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Location
    The Pleiades
    Posts
    299
    Rep Power
    8
    Good morning,

    In PHP, to retrieve all the $_GET values, you can do this:
    Code:
    foreach($_GET as $v)
    {
           echo $v . "<br />";
    }
    If you want to manipulate the data WITHIN the foreach() loop, then you need to pass a reference of the $_GET variable to the foreach() and save it into the same variable passed. This will ensure that the original value in the $_GET array will change as well.

    Let's pretend your array contains filenames - index.php, home.htm, about.htm, portfolio.htm and you only want the name of the file without the extension, you can do this:

    For example:
    Code:
    foreach($_GET as &$v)
    {
           $v = strstr($v, ".", TRUE);
    }
    Code above assumes you only have one period (.) in your filename. Probably better to use strrpos() to find the last occurrence of a period within the string. There are many ways to do it.

    Anyway, that's how you can loop through your $_GET array.

    Kind regards,

    NM.

    Comments on this post

    • mayakanon agrees : Thanks a lot. Its really much helpful. I am glad to you all.

IMN logo majestic logo threadwatch logo seochat tools logo