Click here to Skip to main content
15,889,595 members
Home / Discussions / JavaScript
   

JavaScript

 
QuestionRe: Elements hidden - if visible do something Pin
ZurdoDev21-Mar-17 4:19
professionalZurdoDev21-Mar-17 4:19 
AnswerRe: Elements hidden - if visible do something Pin
Member 1307408621-Mar-17 4:34
Member 1307408621-Mar-17 4:34 
GeneralRe: Elements hidden - if visible do something Pin
ZurdoDev27-Mar-17 1:59
professionalZurdoDev27-Mar-17 1:59 
Questiondataset with java Pin
Member 1307317120-Mar-17 22:01
Member 1307317120-Mar-17 22:01 
AnswerRe: dataset with java Pin
Richard MacCutchan20-Mar-17 23:06
mveRichard MacCutchan20-Mar-17 23:06 
QuestionDisplay PDF in iframe from base64 string using blob url Pin
ankit1819-Mar-17 6:03
ankit1819-Mar-17 6:03 
SuggestionRe: Display PDF in iframe from base64 string using blob url Pin
ZurdoDev20-Mar-17 1:15
professionalZurdoDev20-Mar-17 1:15 
QuestionA more efficient approach? Pin
samflex10-Mar-17 3:54
samflex10-Mar-17 3:54 
Can someone please suggest a different, more efficient approach to the code below?

It works in terms of successfully posting data to the database (phew - too much head banging).

However, it is awfully, inefficient and annoying when you receive a million alert messages saying "Data Added Successfully"

Is there a way to just make it one click to submit all the records?

I tried an idea that did not work.

First here is the code that works with those many alert messages.

PHP
                        function getAllEmpData() {
                            var data = [];
                            $('tr.data-contact-personm').each(function () {
                                var ename = $(this).find('.employeename01').val();
                                var etitle = $(this).find('.employeetitle01').val();
                                var email = $(this).find('.employeeemail01').val();
                                var alldata = {
                                    'emplName': ename,
                                    'emplTitle': etitle,
                                    'empMail': email
                                }
                                data.push(alldata);
                            });
                            console.log(data);
                            return data;
                        }

                        function getAllSourcepData() {
                            var data = [];
                            $('tr.data-contact-person').each(function () {
                                var sname = $(this).find('.sourcename01').val();
                                var saddress = $(this).find('.sourceaddress01').val();
                                var sincome = $(this).find('.sourceincome01').val();
                                var alldata = {
                                    'mySource': sname,
                                    'mySAddress': saddress,
                                    'mySIncome': sincome
                                }
                                data.push(alldata);
                            });
                            console.log(data);
                            return data;
                        }

                        function getAllSpouseData() {
                            var data = [];
                            $('tr.data-contact-person2').each(function () {
                                var spname = $(this).find('.spousename01').val();
                                var spaddress = $(this).find('.spouseaddress01').val();
                                var spincome = $(this).find('.spouseincome01').val();
                                var alldata = {
                                    'mySpouse': spname,
                                    'mySPAddress': spaddress,
                                    'mySPIncome': spincome
                                }
                                data.push(alldata);
                            });
                            console.log(data);
                            return data;
                        }
                        function getAllDividentData() {
                            var data = [];
                            $('tr.data-contact-person3').each(function () {
                                var divname = $(this).find('.dividentname01').val();
                                var divaddress = $(this).find('.dividentaddress01').val();
                                var divincome = $(this).find('.dividentincome01').val();
                                var alldata = {
                                    'myDivName': divname,
                                    'myDivAddress': divaddress,
                                    'myDivIncome': divincome
                                }
                                data.push(alldata);
                            });
                            console.log(data);
                            return data;
                        }
                        function getAllReimbursedData() {
                            var data = [];
                            $('tr.data-contact-person4').each(function () {
                                var reimname = $(this).find('.reimbursmentname01').val();
                                var reimaddress = $(this).find('.reimbursmentaddress01').val();
                                var reimincome = $(this).find('.reimbursmentincome01').val();
                                var alldata = {
                                    'myReimbursName': reimname,
                                    'myReimbursAddress': reimaddress,
                                    'myReimbursIncome': reimincome
                                }
                                data.push(alldata);
                            });
                            console.log(data);
                            return data;
                        }
                        function getAllHonorariaData() {
                            var data = [];
                            $('tr.data-contact-person5').each(function () {
                                var honorname = $(this).find('.inputHonoraria01').val();
                                var alldata = {
                                    'myHonorname': honorname
                                }
                                data.push(alldata);
                            });
                            console.log(data);
                            return data;
                        }
                        function getAllGiftData() {
                            var data = [];
                            $('tr.data-contact-person6').each(function () {
                                var gifname = $(this).find('.giftname01').val();
                                var gifaddress = $(this).find('.giftaddress01').val();
                                var gifincome = $(this).find('.giftincome01').val();
                                var alldata = {
                                    'myGiftname': gifname,
                                    'myGiftaddress': gifaddress,
                                    'myGiftincome': gifincome
                                }
                                data.push(alldata);
                            });
                            console.log(data);
                            return data;
                        }
                        function getAllOrgData() {
                            var data = [];
                            $('tr.data-contact-person7').each(function () {
                                var orgsname = $(this).find('.orgname01').val();
                                var orgsaddress = $(this).find('.orgaddress01').val();
                                var orgsincome = $(this).find('.orgincome01').val();
                                var alldata = {
                                    'myOrgname': orgsname,
                                    'myOrgaddress': orgsaddress,
                                    'myOrgincome': orgsincome
                                }
                                data.push(alldata);
                            });
                            console.log(data);
                            return data;
                        }
                        function getAllCreditorData() {
                            var data = [];
                            $('tr.data-contact-person8').each(function () {
                                var creditname = $(this).find('.creditorname01').val();
                                var creditaddress = $(this).find('.creditoraddress01').val();
                                var creditincome = $(this).find('.creditorincome01').val();
                                var alldata = {
                                    'myCreditorname': creditname,
                                    'myCreditoraddress': creditaddress,
                                    'myCreditorincome': creditincome
                                }
                                data.push(alldata);
                            });
                            console.log(data);
                            return data;
                        }
                        $("#btnSubmit").click(function () {
                            var data = JSON.stringify(getAllEmpData());
                            console.log(data);
                            $.ajax({
                                url: 'closures.aspx/SaveEmpData',
                                type: 'POST',
                                contentType: 'application/json; charset=utf-8',
                                data: JSON.stringify({ 'empdata': data }),
                                success: function () {
                                    alert("Data Added Successfully");
                                },
                                error: function (xhr, status, error) {
                                    alert(xhr.responseText);
                                }
                            });
                        });
                        $("#btnSubmit").click(function () {
                            var data = JSON.stringify(getAllSourcepData());
                            console.log(data);
                            $.ajax({
                                url: 'closures.aspx/SaveSourceData',
                                type: 'POST',
                                contentType: 'application/json; charset=utf-8',
                                data: JSON.stringify({ 'empdata': data }),
                                success: function () {
                                    alert("Data Added Successfully");
                                },
                                error: function (xhr, status, error) {
                                    alert(xhr.responseText);
                                }
                            });
                        });
                        $("#btnSubmit").click(function () {
                            var data = JSON.stringify(getAllSpouseData());
                            console.log(data);
                            $.ajax({
                                url: 'closures.aspx/SaveSpousData',
                                type: 'POST',
                                contentType: 'application/json; charset=utf-8',
                                data: JSON.stringify({ 'empdata': data }),
                                success: function () {
                                    alert("Data Added Successfully");
                                },
                                error: function (xhr, status, error) {
                                    alert(xhr.responseText);
                                }
                            });
                        });
                        $("#btnSubmit").click(function () {
                            var data = JSON.stringify(getAllDividentData());
                            console.log(data);
                            $.ajax({
                                url: 'closures.aspx/SaveDividentData',
                                type: 'POST',
                                contentType: 'application/json; charset=utf-8',
                                data: JSON.stringify({ 'empdata': data }),
                                success: function () {
                                    alert("Data Added Successfully");
                                },
                                error: function (xhr, status, error) {
                                    alert(xhr.responseText);
                                }
                            });
                        });
                        $("#btnSubmit").click(function () {
                            var data = JSON.stringify(getAllReimbursedData());
                            console.log(data);
                            $.ajax({
                                url: 'closures.aspx/SaveReimbursedData',
                                type: 'POST',
                                contentType: 'application/json; charset=utf-8',
                                data: JSON.stringify({ 'empdata': data }),
                                success: function () {
                                    alert("Data Added Successfully");
                                },
                                error: function (xhr, status, error) {
                                    alert(xhr.responseText);
                                }
                            });
                        });
                        $("#btnSubmit").click(function () {
                            var data = JSON.stringify(getAllHonorariaData());
                            console.log(data);
                            $.ajax({
                                url: 'closures.aspx/SaveHonorariaData',
                                type: 'POST',
                                contentType: 'application/json; charset=utf-8',
                                data: JSON.stringify({ 'empdata': data }),
                                success: function () {
                                    alert("Data Added Successfully");
                                },
                                error: function (xhr, status, error) {
                                    alert(xhr.responseText);
                                }
                            });
                        });
                        $("#btnSubmit").click(function () {
                            var data = JSON.stringify(getAllGiftData());
                            console.log(data);
                            $.ajax({
                                url: 'closures.aspx/SaveGiftData',
                                type: 'POST',
                                contentType: 'application/json; charset=utf-8',
                                data: JSON.stringify({ 'empdata': data }),
                                success: function () {
                                    alert("Data Added Successfully");
                                },
                                error: function (xhr, status, error) {
                                    alert(xhr.responseText);
                                }
                            });
                        });
                        $("#btnSubmit").click(function () {
                            var data = JSON.stringify(getAllOrgData());
                            console.log(data);
                            $.ajax({
                                url: 'closures.aspx/SaveOrgData',
                                type: 'POST',
                                contentType: 'application/json; charset=utf-8',
                                data: JSON.stringify({ 'empdata': data }),
                                success: function () {
                                    alert("Data Added Successfully");
                                },
                                error: function (xhr, status, error) {
                                    alert(xhr.responseText);
                                }
                            });
                        });
                        $("#btnSubmit").click(function () {
                            var data = JSON.stringify(getAllCreditorData());
                            console.log(data);
                            $.ajax({
                                url: 'closures.aspx/SaveCreditorData',
                                type: 'POST',
                                contentType: 'application/json; charset=utf-8',
                                data: JSON.stringify({ 'empdata': data }),
                                success: function () {
                                    alert("Data Added Successfully");
                                },
                                error: function (xhr, status, error) {
                                    alert(xhr.responseText);
                                }
                            });
                        });
                    });
                 });
              });
            });
           });
          });
         });
       });
    });
</script>

AnswerRe: A more efficient approach? Pin
Nathan Minier16-Mar-17 4:41
professionalNathan Minier16-Mar-17 4:41 
GeneralRe: A more efficient approach? Pin
samflex17-Mar-17 3:01
samflex17-Mar-17 3:01 
AnswerRe: A more efficient approach? Pin
ZurdoDev16-Mar-17 5:38
professionalZurdoDev16-Mar-17 5:38 
QuestionOK, What Am I doing Wrong ???? Pin
Kevin Marois8-Mar-17 6:43
professionalKevin Marois8-Mar-17 6:43 
AnswerRe: OK, What Am I doing Wrong ???? Pin
Richard Deeming8-Mar-17 8:06
mveRichard Deeming8-Mar-17 8:06 
GeneralRe: OK, What Am I doing Wrong ???? Pin
Kevin Marois8-Mar-17 8:08
professionalKevin Marois8-Mar-17 8:08 
GeneralRe: OK, What Am I doing Wrong ???? Pin
Richard Deeming8-Mar-17 8:10
mveRichard Deeming8-Mar-17 8:10 
GeneralRe: OK, What Am I doing Wrong ???? Pin
Kevin Marois8-Mar-17 8:11
professionalKevin Marois8-Mar-17 8:11 
GeneralRe: OK, What Am I doing Wrong ???? Pin
Richard Deeming8-Mar-17 8:13
mveRichard Deeming8-Mar-17 8:13 
GeneralRe: OK, What Am I doing Wrong ???? Pin
Kevin Marois8-Mar-17 8:17
professionalKevin Marois8-Mar-17 8:17 
GeneralRe: OK, What Am I doing Wrong ???? Pin
Richard Deeming8-Mar-17 8:22
mveRichard Deeming8-Mar-17 8:22 
GeneralRe: OK, What Am I doing Wrong ???? Pin
Kevin Marois8-Mar-17 8:26
professionalKevin Marois8-Mar-17 8:26 
GeneralRe: OK, What Am I doing Wrong ???? Pin
Kevin Marois8-Mar-17 8:27
professionalKevin Marois8-Mar-17 8:27 
GeneralRe: OK, What Am I doing Wrong ???? Pin
Richard Deeming8-Mar-17 8:40
mveRichard Deeming8-Mar-17 8:40 
GeneralRe: OK, What Am I doing Wrong ???? Pin
Kevin Marois8-Mar-17 8:42
professionalKevin Marois8-Mar-17 8:42 
GeneralRe: OK, What Am I doing Wrong ???? Pin
Richard Deeming8-Mar-17 8:53
mveRichard Deeming8-Mar-17 8:53 
GeneralRe: OK, What Am I doing Wrong ???? Pin
Kevin Marois8-Mar-17 10:28
professionalKevin Marois8-Mar-17 10:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.