[thelist] Solution to - How to auto poplulate next text box (User form input question)

Brian Delaney brian.delaney at mccmh.net
Fri Apr 8 06:41:50 CDT 2005


The clerk enters a code and tehnext text box auto fills the name. IF the 
name does't exist an alert is posted.
The code is inserted betweed the <HEAD> tags. I use asp recordset to 
retrieve the names.
the code:
<HEAD>
<script language="javascript">
       
         function checkagencies()
        {       
        var c=document.frmIncident.txtAgencyCode;
        var n=document.frmIncident.txtAgencyName;
        var agencynamearray = new Array();
        var agencycodearray = new Array();       
        c.onchange=function()
        {
        <%
        Call OpenORRDBConn()
        Set rsAgency = Server.CreateObject("ADODB.Recordset")
        strSQL = "SELECT ID, AgencyNo, AgencyName from Agencies order by 
AgencyNo"
        rsAgency.Open strSQL, ORRDBConn
       
        intCount = 0
        do until rsAgency.eof
            strName = trim(rsAgency("agencyname"))
            strCode = trim(rsAgency("agencyno"))
            response.write "agencynamearray[" & intCount & "]=""" & 
strName & """;"
            response.write "agencycodearray[" & intCount & "]=""" & 
strCode & """;"
            intCount = intCount + 1
            rsAgency.movenext
        loop
        %>
        for (i=0; i <= <%=intCount%>; i++)
                {
               
                if (frmIncident.txtAgencyCode.value == agencycodearray[i])
                    {
                    n.value=agencynamearray[i];       
                    var found = true;
                    return;
                    } //end if
                } //end for
               
                if (found != true)
                    {
                    c.focus();
                    alert("Agency name not found, please check the 
entered Agency Code");
                   
                }//end for
       
        }//end onchange
    }//end function
    window.onload=function()
    {
        checkagencies();
    }

</script>
    </head>

Shaun Clements wrote:

>Populate the list box with all the agencies (ASP).
>Then on the left of that, provide an input box, and allow the user to enter
>in the code.
>Use a javascript function on blur of the input box, to loop through the list
>box, and select the correct agency from the code supplied.
>
>Let me know if you need the code for the javascript function
>
>Kind Regards,
>Shaun Clements
>
>
>-----Original Message-----
>From: Brian Delaney [mailto:brian.delaney at mccmh.net]
>Sent: 04 April 2005 03:05 PM
>To: thelist at lists.evolt.org
>Subject: [thelist] User form input question
>
>
>Ok, this is another user request that I am not sure how to pull off:
>
>There are about 200 agencies. The agency table contains an ID, name and 
>code.
>
>During data entry the clerks know the agency code before the name.
>
>The would like to be able to enter the code and have the next field auto 
>populate with name.
>
>I have a record set with the Agency info that it retrieved when the page 
>first  loads.
>
>I am using asp, javascript, html on IIS with sql 2000 backend.
>
>Thanks,
>BD
>
>*
>*
>*
>This message, including any attachments, is intended solely for the use of
>the named recipient(s) and may contain confidential and/or priveleged
>information.  Any unauthorized review, use, disclosure or distribution of
>this communication(s) is expressly prohibited.  If you are not the intended
>recipient, please contact the sender by reply e-mail and destroy any and all
>copies of the original message.
>  
>

*
*
*
This message, including any attachments, is intended solely for the use of the named recipient(s) and may contain confidential and/or priveleged information.  Any unauthorized review, use, disclosure or distribution of this communication(s) is expressly prohibited.  If you are not the intended recipient, please contact the sender by reply e-mail and destroy any and all copies of the original message.


More information about the thelist mailing list