Skip to content
Loading
How to get textbox value into php query from javascript & html
  1. $(document).ready(function()  
  2. {  
  3. $(".delete").on("click"function() {  
  4. $(".case:checkbox:checked").parents("tr").remove();  
  5. $(".check_all").prop("checked"false);  
  6. check();  
  7. });  
  8. var counter = $("table tr").length - 1;  
  9. $(".addmore").on("click"function(){  
  10. var ail = $("#ail_select").val();  
  11. if (ail.length > 0) {  
  12. counter++;  
  13. var data = " + counter + "'>" + ail + ".";  
  14. data += " + counter + "' name='countryname[]' required value=''/>";  
  15. data += "";  
  16. $("table").append(data);  
  17. // var datval = $('#datval').val();  
  18. var val = document.getElementById("countryname_" + counter + "").value;  
  19. }  
  20. });  
  21. });  
  22. //......ajax..  
  23. function getdet()  
  24. {  
  25. var datval = $('#datval').val();  
  26. var name = $('#name').val();  
  27. var result={"name": name};  
  28. $.ajax({  
  29. url: "sample.php",  
  30. type: "POST",  
  31. data: {"name": name,},  
  32. success: function () {  
  33. console.log('Updated');  
  34. },  
  35. error: function (err)  
  36. {  
  37. console.log(err);  
  38. }  
  39. });  
  40. }  

6 Replies

Know the answer? Post it — somebody with the same question will find it here.