Solved

insert multiple rows into database

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
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…

734 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