-1
我很新,请帮我这个.. 我可以只显示名字,但我一定要显示年龄,出生日期也索引页,我已经创建的输入形式平变化的HTML和PHP
check.php我只能发送一个数据,所以我怎么可以给年龄,出生日期也与如何获得,在索引页
的index.php
<html>
<head>
<script type='text/javascript'>
function validate(field)
{
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() // Checking if readyState changes
{
if (xmlhttp.readyState==4 && xmlhttp.status==200) // Validation Completed
{
document.getElementById("name").value = xmlhttp.responseText;
}
}
xmlhttp.open("GET","check.php?field="+field+, false);
xmlhttp.send();
}
</script>
</head>
<body>
<form name="gt" id="gt" action="Form_Action.php" method="post" >
<table>
<tr>
<td>Userid</td>
<td><input type='text' name='userid' id='userid' onchange="validate(this.value)"></td>
<td></td></tr>
<tr><td>name</td>
<td><input type='text' name='name' id='name' ></td>
<td></td>
</tr>
<tr><td>age</td>
<td><input type='text' name='age' id='age'></td>
<td></td>
</tr>
<tr><td>dob</td>
<td><input type='text' name='dob' id='dob'></td>
<td></td>
</tr>
</table>
<input type='submit' value='Submit'>
</form>
</body>
</html>
check.php
<?php
include('connect.php');
$field= $_GET['field'];
$res=mysql_query("Select userid,name,age,dob from user where userid='$field' ");
while($row=mysql_fetch_row($res))
{
echo "$row[0]";
}
?>
可能重复(http://stackoverflow.com/问题/ 11661187/form-serialize-javascript-no-framework) – Ohgodwhy
请缩小你的代码到实际上令人失望的地方。也试着提出一个明确的问题。 –