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

    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    Post How to pass an array of elements to a function in java script??


    How to pass an array of elements to a function in java script from php code of same code file, on button click event.

    Detail Description of Problem:

    1) we will check/uncheck some checkboxes
    2) those checkboxs names which are checked should be stored in an array.
    3) on click of a button, those array values will be sent to a database query, which will return the table details of those names in database.
    4) those returned values should be desplaied in atable formate in browser.


    now problem is i'm not getting how to write code for this.

    ple help me out with a simple solution/code.
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,041
    Rep Power
    119
    Not going to write the code for you, because then what would be the purpose of me doing YOUR homework; you wouldn't learn anything like that. Although... I will tell you how to begin.

    1.) Get the value(s) from your checkbox(s) and validate, as needed.
    2.) Then take the checkbox values and use a JavaScript push() prototype; to add the values into the array. You can do it without the prototype; but this would be the easiest way.
    3.) Insert the array key(s) into an AJAX query; to preform a database query (from your server side page).
    4.) Use AJAX to retrieve the responseText (from your server side page) and then... use that responseText to display the data, in your table.

    And then... your done; good luck.

IMN logo majestic logo threadwatch logo seochat tools logo