Solved

insert multiple rows into database

Posted on 2010-11-16
4
283 Views
Last Modified: 2013-11-18
I am adding multiple rows to a table dynamically using jquery. I am creating the IDs also dynamically based on the values selected.

I need to insert these multiple rows into the database using coldfusion. I am stuck as to how to pass the dynamic data from the CFM to the CFC

Please help.
0
Comment
Question by:sshivanna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 16

Expert Comment

by:Gurpreet Singh Randhawa
ID: 34152397
can u show me some code what exactly are you trying to do!

which database you are using also!

you can always use the cfloop statement an dwrap the query inside to loop around the form values, but it depends which database you are using! If you can show some that will help a lot in debugging your information
0
 
LVL 2

Accepted Solution

by:
sshivanna earned 0 total points
ID: 34155545
Thank you for responding. I was able to figure out a solution for this problem. My basic challenge was, that the data is dynamic. I was able to commit multiple rows to the database with a combination of jQuery and Coldfusion.

The coldfusion CFC code is very simple. All I do is a basic insert by taking the parameters as arguments.

Here is the jquery & javascript code where I am submitting ajax inserts in a loop.

            $("#btn_insertRoles").click(function(){
                  
                  //alert($("#roles_ssoid").val()+' '+ $("#rt1").html()+' '+$("#r1").html()+' '+$("#a1").html());

                  for(i=1;i<=$("#recCount").val();i++) {
                        $.ajax({
                            type: 'POST',
                            url: "<git:docroot/>ajax/insertGitUserRoles",
                            async: false,
                            data: {
                                ssoid : $("#roles_ssoid").val(),
                                roletype : $("#rt"+i).html(),
                                role : $("#r"+i).html(),
                                approver: $("#a"+i).html()
                            },
                            success: function(data, textStatus, xhr) {
                                    if (i==$("#recCount").val()){
                                      GIT.growl.ok(data);
                                    }
                                    //Clear the values of the form.
                            },
                            error: function(data, textStatus, xhr) {
                                GIT.growl.error(data.responseText);
                            },
                            dataType: 'text'
                        });
                  }                  

            });
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Non-Resizable Pharagraph 2 17
JS library vs Js framework 11 20
window close link 7 32
Word Press Fixes to Google Speed Test Issues 2 20
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question