tapaljor tapaljor - 2 months ago 9
Ajax Question

How to pass value of multiple input form in jQuery ajax?

I have multiple input form. Once I put value and I should able to pass it through jQuery Ajax. It's working on simple html form. But in terms of multi-dimension form I fail.

Please help me get value in jQuery.

I have html form

<form action="index.php" method="POST">
<?php
for($a=0; $a<5; $a++) {
echo "<input type='text' name='IdentityID[]' placeholder='GB' onchange=\"getdetail(IdentityID[id]); return false;\"/>";
}
?>
</form>


JQuery ajax

function getdetail(IdentityID) {

alert(IdentityID); //I wan the value to appear here

$.ajax ({
type: "POST",
url: "getdetail.php",
data: { IdentityID: IdentityID},
success: function(data) {
$("#detail").html(data);
}
});
return false;
}



ReferenceError: IdentityID is not defined

Answer

Substitute this.value for IdentityID[id] at onchange=\"getdetail(IdentityID[id])

Comments