Solved

insert multiple rows into database

Posted on 2010-11-16
4
282 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
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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

831 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