+ Reply to Thread
Results 1 to 6 of 6

Thread: Post JS Array to PHP

  1. #1
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    Post JS Array to PHP

    I've googled this up already, but everything is very confusing for me. (I totally fail at JS)

    I have an array in JS, and I need to get it to PHP to process and dump the information into the database.

  2. #2
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: Post JS Array to PHP

    http://www.hscripts.com/tutorials/php/jsArrayToPHP.php seems to give a quite good example.

    If you don't want to have a form though (you could hide it), you could create an advance system using cookies and AJAX and server partial request/response
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

  3. #3
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    Re: Post JS Array to PHP

    Quote Originally Posted by xav0989 View Post
    http://www.hscripts.com/tutorials/php/jsArrayToPHP.php seems to give a quite good example.

    If you don't want to have a form though (you could hide it), you could create an advance system using cookies and AJAX and server partial request/response
    I don't get Step 4 where you have to split the string back to an array in PHP, they don't say how.

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Post JS Array to PHP

    What type of data? The answer will affect the generality of the solution.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  5. #5
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    Re: Post JS Array to PHP

    Code:
    # dpGetSelected( ) returns Array
    Gets a list of Dates currently selected by this datePicker. This will be an empty array if no dates are currently selected or NULL if there is no datePicker associated with the matched element.
    Example:
    
    Will alert an empty array (as nothing is selected yet)
    
    $('.date-picker').datePicker();
    alert($('.date-picker').dpGetSelected());
    http://www.kelvinluck.com/assets/jqu...mentation.html

  6. #6
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: Post JS Array to PHP

    Quote Originally Posted by diabolo View Post
    I don't get Step 4 where you have to split the string back to an array in PHP, they don't say how.
    The fourth part is quite easy to write (I wrote it myself):

    PHP Code:
    <?php

    $data 
    $_POST['arv']; //you need to sanitize it, though

    $array explode(","$data);

    ?>
    Last edited by xav0989; 09-26-2009 at 10:15 AM.
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

+ Reply to Thread

Similar Threads

  1. Help with php array
    By RossSchVle in forum Programming Help
    Replies: 3
    Last Post: 11-09-2008, 07:36 AM
  2. Cambios IMPORTANTES en PHP.
    By Fedlerner in forum Noticias y Anuncios
    Replies: 1
    Last Post: 11-06-2007, 11:13 AM
  3. Sigo con problemas con phpbb2
    By reciecho in forum Soporte
    Replies: 7
    Last Post: 10-20-2007, 06:28 PM
  4. PHP Help (Searching array then delete if found)
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 4
    Last Post: 02-23-2006, 03:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers