javascript - Onchange in HTML and PHP -
i new please help me this.. can display name have display age, dob in index page have created input form
in check.php can send 1 info how can send age, dob , how in index page
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 user userid='$field' "); while($row=mysql_fetch_row($res)) { echo "$row[0]"; } ?> i don't know if understood you..without javascript can follows:
index.php
<html> <head> <title>whatever</title> </head> <body> <form name="gt" id="gt" action="check.php" method="post" > <!-- notice form action in check.php create sure give right location--> <table> <tr> <td>userid</td> <td><input type='text' name='userid' id='userid' ></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 $userid = $_post['userid'];//since form has post method in index.php $name = $_post['name']; $age = $_post['age']; //you can either set database mysql query or display below echo $userid; echo "<br/>"; echo $name; echo "<br/>"; echo $age; echo "<br/>"; ?> javascript php jquery html ajax
No comments:
Post a Comment