Friday 15 August 2014

php - Multiple/Single Dropdown using AJAX/JQuery, autocomplete saved in options and then fill the input -



php - Multiple/Single Dropdown using AJAX/JQuery, autocomplete saved in options and then fill the input -

i have script:

function showuser(str) { if (str=="") { document.getelementbyid("txthint").innerhtml=""; return; } if (window.xmlhttprequest) { // code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else { // code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { document.getelementbyid("txthint").innerhtml=xmlhttp.responsetext; } } xmlhttp.open("get","getuser.php?q="+str,true); xmlhttp.send(); }

and php

<?php $result = mysqli_query($con, "select * visa order idvisa"); ?> <form> <div align="center"> <td><select name="users" onchange="showuser(this.value)"> <option value="">select person:</option> <? while ($row=mysqli_fetch_array($result)) { echo "<option value='{$row['idvisa']}' visanumber='{$row['visanumber']}' idnumber='{$row['idnumber']}' statusapp='{$row['statusapp']}' accntvisaphotopath='{$row['accntvisaphotopath']}' passportpath='{$row['passportpath']}' subdate='{$row['subdate']}'>".$row['fname']." ".$row['lname']."</option>"; } echo "</select> </td> <td><div id=\"txthint\">(empty)</div></td> </td> </div> <br><br> <div align=\"center\"> <td><select name=\"users1\" onchange=\"showuser(this.value)\"> <option value=\"\">select person:</option> <option value='{$row['idvisa']}' visanumber='{$row['visanumber']}' idnumber='{$row['idnumber']}' statusapp='{$row['statusapp']}' accntvisaphotopath='{$row['accntvisaphotopath']}' passportpath='{$row['passportpath']}' subdate='{$row['subdate']}'>".$row['fname']." ".$row['lname']."</option>"; ?> </select> </td> <td><div id=\"txthint\">(empty)</div></td> </td> </div> ?>

and getuser.php

<?php $q = intval($_get['q']); $sql="select * visa idvisa = '".$q."'"; $result = mysqli_query($con,$sql); echo "<table border='1'> <tr> <th> <div align=\"center\">visa number</div></th> <th> <div align=\"center\">id number </div></th> <th> <div align=\"center\">employment status</div></th> <th> <div align=\"center\">&nbsp;visa&nbsp;</div></th> <th> <div align=\"center\">&nbsp;passport&nbsp;</div></th> <th> <div align=\"center\"><font color=\"red\">elapse</div></th> </tr>"; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['visanumber'] . "</td>"; echo "<td>" . $row['idnumber'] . "</td>"; echo "<td>" . $row['statusapp'] . "</td>"; echo "<td align=\"center\"><img src=\"http://www.lab.workforceint.com/" . $row['accntvisaphotopath'] ." \"height=\"50\" width=\"50\" \"></td>"; echo "<td align=\"center\"><img src=\"http://www.lab.workforceint.com/" . $row['passportpath'] ." \"height=\"50\" width=\"50\" \"></td>"; echo "<td>" . $row['subdate'] . "</td>"; echo "</tr>"; } echo "</table>";

and link contract

questions:

how come sec drop-down not displaying? can have 10 drop-downs although have same script?

i trying find here though working on ajax , jquery (really noob), sec script in 3 days already. please help or advise me on should do.

php jquery ajax mysqli

No comments:

Post a Comment