?
Solved

insert multiple rows into database

Posted on 2010-11-16
4
Medium Priority
?
287 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
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…
Suggested Courses

752 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