Great day :) I want to get 'id='countryname_" + counter + "'' value from javascript,then pass the value to ajax function.I have tried few methods but its doesn't work.can you please help me to get a great output.
- class="row">class="col-md-6">
- "text" id='name' name="Name" value="">
- Select:
- name="ail_select">
- >--- Select ---
- >Access card
- >Vehicle
- class='btn btn-success addmore'>+ Add More
- class="row">class="col-sm-6">
- class="fw-separator">
- ="previous-form action-button color-bg" id ="sub"; onclick ="getdet()" name="sub">Update Details
- $(document).ready(function()
- {
- $(".delete").on("click", function() {
- $(".case:checkbox:checked").parents("tr").remove();
- $(".check_all").prop("checked", false);
- check();
- });
- var counter = $("table tr").length - 1;
- $(".addmore").on("click", function(){
- var ail = $("#ail_select").val();
- if (ail.length > 0) {
- counter++;
- var data = "
";+ counter + "'>" + ail + ". ";- data += "
+ counter + "' name='countryname[]' required value=''/> ";- data += "
- data += "
- $("table").append(data);
- // var datval = $('#datval').val();
- var val = document.getElementById("countryname_" + counter + "").value;
- }
- });
- });
- //......ajax..
- function getdet()
- {
- var datval = $('#datval').val();
- var name = $('#name').val();
- var result={"name": name};
- $.ajax({
- url: "sample.php",
- type: "POST",
- data: {"name": name,},
- success: function () {
- console.log('Updated');
- },
- error: function (err)
- {
- console.log(err);
- }
- });
- }
6 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
karthika pommuduPosted Jul 21, 2020, 10:18 PM
Laxmidhar SahooPosted Jul 17, 2020, 5:01 AM
karthika pommuduPosted Jul 16, 2020, 3:07 AM
Laxmidhar SahooPosted Jul 16, 2020, 2:59 AM
karthika pommuduPosted Jul 16, 2020, 2:45 AM
Laxmidhar SahooPosted Jul 16, 2020, 2:38 AM