Click here to Skip to main content
15,065,044 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friends,
i have this table

XML
jQtable=$('#SaleTable');
        jQtable.each(function()
        {
            var LastRow="<TR><TD align=center><INPUT TYPE='text' name='Slno' id='Slno' size=1></TD><TD align=center><INPUT type='checkbox' name='in_travel' ID='in_travel' value='in_terval'  size=10></TD><TD align=center><INPUT type='text' name='date' ID='date' size=10></TD><TD align=center><textArea name='cities_visit' ID='cities_visit' cols=10></textArea></TD><td align=center><select id='reimbursement' name='reimbursement'><option selected='selected' value='None'>--None--</option><option value='DA'>DA</option><option value='Ticket'>Ticket</option><option value='Misc'>Misc</option></select></td><TD align=center><textArea name='Remark' ID='Remark' cols=10></textArea></TD><TD align=center><INPUT style='text-align:right' type='checkbox' name='bills' ID='bills' value='bills' size=10></TD><TD align=center><INPUT style='text-align:right' type='submit' name='submit' ID='submit' onclick='getvalue()' value='Submit' size=10></TD><TD align=center></TR>";
         // $(this).append(LastRow);
     $(LastRow).find(':submit').click(getvalue).end().appendTo('#SaleTable');
            });
RowCount++;
    }


function getvalue()

C#
function getvalue() {
    var row = $(this).closest('tr');
    var sl = $('input:text[name^="Slno_"]', row).val();
    alert(sl);
    var in_tra = $('input[name^="in_travel_"]:checked', row).val();
    alert(in_tra);
     var date = $('input:text[name^="date_"]', row).val();
    alert(date);
    var cities = $('textarea[name^="cities_visit_"]', row).val();
    alert(cities);
    var slect = $('select[name^="reimbursement_"]', row).val();
    alert(slect);
    var remarks = $('textarea[name^="Remark_"]', row).val();
    alert(remarks);
    var bills = $('input[name^="bills_"]:checked', row).val();
    alert(bills);
}


i want to store these values into database by using jquery.

Thanks
Posted

i want to store these values into database by using jquery.
And what is the issue? Since you want to save data, you need to talk to server. To talk to server via jQuery, you need to use AJAX.
Look here on how to use jQuery Ajax:
http://api.jquery.com/jQuery.ajax/[^]
http://api.jquery.com/category/ajax/[^]
http://www.w3schools.com/jquery/jquery_ref_ajax.asp[^]
   
Comments
[no name] 30-Aug-12 5:06am
   
I had already gone through these links,
In these link data is coming from other page but in my case i am taking data from same page.

Thanks
andrewfreeboy 5-Jul-13 7:40am
   
HOW TO ADD DATA IN HTML PAGE USING JQUERY AND MVC3 TO INSERT DATA INTO SSQL SERVER DATABASE... CAN YOU HELP ME WITH THE SOLUTION
andrewfreeboy 5-Jul-13 7:43am
   
I have a html button with three text box values Name, Score and Enrollment, I need to insert this into Sql Server database using MVC3 and Jquery... I am New to MVC. Please help me with a solution...
Thank You... :)
Here is the page code

C#
$("#submit_ta").click(function(){

     var name = $("#name").val();
     var rm_from = $("#reimbursement_from").val();
     var rm_to = $("#reimbursement_to").val();
     var cities = $("#cities_visited").val();
     var nofdays = $("#nofdays_ta").val();
     if ($('#bills_ta').is(':checked')) {
    var bills="Yes";
} else {
    var bills="No";
}
    // var bills =  $('input[name="bills_ta"]:checked').val();
     var remarks = $("#remarks_ta").val();
     var amount=$("#amount_ta").val();

  $.post('add-data-sql-ta.php',{name: name, rm_from: rm_from, rm_to: rm_to, cities: cities, nofdays: nofdays, bills: bills,
  remarks: remarks,amount: amount},
  function(data){
  $("#message_ta").html(data);
  $("#message_ta").hide();
  $("#message_ta").fadeIn(1500); //Fade in the data given by the insert.php file
    });//post
    return false;
});//click


and in add-data-sql-ta.php file you use you get these values and use simple insert query.

Thanks
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900