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

    Join Date
    Jun 2011
    Posts
    60
    Rep Power
    4

    Pass Javascript Array values to database table using coldfusion


    Hi Peers,

    Is there a way to insert javascript array values into a databse using Coldfusion language ?


    thanks
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,273
    Rep Power
    968
    Again, it seems like you're missing the point that JavaScript runs in the browser and CF runs on the server, just like PHP, ASP.NET, and every other web scripting language. So you can issue POST or GET HTTP requests to the ColdFusion server and pass whatever values you want to. Which generally involves submitting a form or executing an AJAX request.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Posts
    60
    Rep Power
    4
    Hi Kiteless,

    No i am not missing that part. It is very clear for me since you mentioned that to me in previous posts.
    Basically, based on what you said i am not able to create a connectoin between Java and CF ..looking for small example

    Thanks
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,273
    Rep Power
    968
    The "connection" that you're talking about is an HTTP request. That's just how data gets from the browser to the server. So you can just post a form to the server, or you can run an AJAX request, which makes an "invisible" HTTP request, so the user's browser stays on the same page.

    CF has a number of tools to help with AJAX that are thoroughly covered in the documentation. But if you want the easiest solution, just have the user submit a form.
    Last edited by kiteless; August 4th, 2011 at 11:36 AM.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Posts
    60
    Rep Power
    4
    HI Kiteless,

    i have ben alble to capture the javascript values in one form field instead of several fields like this :
    formfield1 = "value1,value2,value3,..."

    Now i need to insert them into a database using the following statment :

    INSERT INTO TABLE (tablefield1,tablefield1.tablefield1) VALUES (value1,value2,value3)

    i have to call the formfield1 content instead of the value1,2,3..
    any help on that or other idea ?

    thanks
  10. #6
  11. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,273
    Rep Power
    968
    Do you want to insert them all into one database row, or do you want them in separate database rows?
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Posts
    60
    Rep Power
    4
    Diff db rows they are diff values for diff projets
    Tnx
  14. #8
  15. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,273
    Rep Power
    968
    Then you need to loop over the list and do an insert for each one (which will create separate rows).

IMN logo majestic logo threadwatch logo seochat tools logo