I am developing an entry form. In the form there are two textbox. In one textbox when I type a keyword a DIV is opened and customer list having customerid and customername is displayed.
<form name="form1" action="">
customerid : <input type=text id="cusid" />
customername: <input type="text" id="custnm" onkeyup="showHint(this.value);" />
</form>
<div id="txtHint" style="width:250; background-color:cyan; display:none; ">
</div>
The customer list is displayed using ajax. Now in the list I have hyperlink on the CustomerID.
I want to return the customerID from the list back to the cusid textbox when user clicks the link. Also when user hits the tab button controls should transfer to the customer list. the same trigger should fire when user hits enter button and selected customerid should get filled in CUSId textbox.
Below is the procedure for ajax.
function showHint(str) {
var xhttp;
if (str.length == 0) {
document.getElementById("txtHint").innerHTML = "";
return;
}
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("txtHint").style.display="inline";
document.getElementById("txtHint").innerHTML = xhttp.responseText;
}
};
xhttp.open("post", "getemp.asp?q="+str+"", true);
xhttp.send();
}
this is the getemp.asp file
sernm=request("q")
response.Write "<table>"
ks.open "select customer,customerid from customer where customername like '"&sernm&"%'",conn
if not ks.eof then
while not ks.eof
vid=ks(1):if isnull(vid) or trim(vid)="" then vid=0
acname=ks(0)
'response.Write empnm &" "& ad1 &" "& ad2 &" "& ad3 &"<br>"
response.Write "<tr>"
%>
<td><a href="" onclick="return CloseWind('12');" ><%=vid%></a></td>
<%
response.Write "<td>"&acname&"</td>"
response.Write "</tr>"
ks.movenext
wend
end if
ks.close
response.Write "<table>"
This is the javascript for getting customerID
<script language="javascript">
function CloseWind(VID)
{
document.forms['form1'].elements[CUSID].value=VID;
return false;
}
</script>
How could i get the customerid in the main form.
This is the same when we try to do voucher entry in tally.