here’s the code:
<input type="text" id="participant1" name="name[1][]" value="Andi"/> </p>
<input type="text" id="idparticipant1" name="idparticipant[1][]" value="1001"/>
<input type="text" id="participant2" name="name[2][]" value="Smith"/> </p>
<input type="text" id="idparticipant2" name="idparticipant[2][]" value="1005" />
here’s the jquery script:
<script src="jquery-1.4.js"></script>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="jquery.autocomplete.js"></script>
<link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
<script>
$(document).ready(function()
{
$('[id^="participant"]').keyup(function()
{
var txt = $(this).val();
$.ajax({
type: "POST",
url: "blue.php",
data: "nameparticipant=" + txt,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data)
{
$(this).next().val(data.d);
//alert(data.d);
}
//failure: failerEvent
});
});//keyup
});
</script>
script of blue.php
<?php
$nameparticipant=$_POST["nameparticipant"]);
$res = mysql_query("select * from table where upper(name) like '$nameparticipant%'");
$t=mysql_fetch_array($res);
echo"$t[nik]";
?>
When i keyup input name of participant other than the name “Andy”, i’d like is value id changing to 0. and when i turn it over again then its value id changed to be like the beginning.
What can i do?
use
instead of
remove unneccesory
<p>tags from the code,JavaScript,
working sample