Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Auto fill textbox

    I have a form that includes 2 text input. I'd like the second text input to fill with the value selected from database based on the first textbox value, by default when the first text input loses focus. What methods should I look into to learn to do this?please help me as soon as possible....

  • #2
    New Coder
    Join Date
    Apr 2004
    Location
    Columbus, Ohio
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think that sounds more like a javascript question
    Hate something?
    Tell us about it
    Go Complain

  • #3
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Or you could use Ajax to pull info from the database. You would have to give more details about the script and database setup.

    http://www.dynamicdrive.com/dynamici...jaxcontent.htm

  • #4
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <!--#include file="db.asp" -->
    <%
    Dim Recordset1
    Dim Recordset1_numRows
    
    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.ActiveConnection = conn
    Recordset1.Source = "SELECT user_name FROM ajax_user"
    Recordset1.CursorType = 0
    Recordset1.CursorLocation = 2
    Recordset1.LockType = 1
    Recordset1.Open()
    
    Recordset1_numRows = 0
    %>
    <%
    Dim Repeat1__numRows
    Dim Repeat1__index
    
    Repeat1__numRows = -1
    Repeat1__index = 0
    Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    <script type="text/javascript">
    
    /***********************************************
    * Dynamic Ajax Content- &#169; Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    
    var loadedobjects=""
    var rootdomain="http://"+window.location.hostname
    
    function ajaxpage(url, containerid){
    var page_request = false
    if (window.XMLHttpRequest) // if Mozilla, Safari etc
    page_request = new XMLHttpRequest()
    else if (window.ActiveXObject){ // if IE
    try {
    page_request = new ActiveXObject("Msxml2.XMLHTTP")
    } 
    catch (e){
    try{
    page_request = new ActiveXObject("Microsoft.XMLHTTP")
    }
    catch (e){}
    }
    }
    else
    return false
    page_request.onreadystatechange=function(){
    loadpage(page_request, containerid)
    }
    page_request.open('GET', url, true)
    page_request.send(null)
    }
    
    function loadpage(page_request, containerid){
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
    document.getElementById(containerid).value=page_request.responseText
    }
    </script>
    <script type="text/javascript">
    /***Combo Menu Load Ajax snippet**/
    function ajaxcombo(selectobjID, loadarea){
    var selectobj=document.getElementById? document.getElementById(selectobjID) : ""
    if (selectobj!="")
    //alert('populate_form_getEmail.asp?name=' + selectobj.value + ', ' + loadarea)
    ajaxpage('populate_form_getEmail.asp?name=' + selectobj.value, loadarea)
    }
    </script>
    <style type="text/css">
    <!--
    .style2 {font-size: small}
    -->
    </style>
    </head>
    
    <body>
    <form name="form1" method="post" action="">
      <p>Name 
        <input name="name" type="text" id="name" onblur="ajaxcombo('name','email')">
        (<% 
    While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) 
    %>
        <%=(Recordset1.Fields.Item("user_name").Value)%>, 
        <% 
      Repeat1__index=Repeat1__index+1
      Repeat1__numRows=Repeat1__numRows-1
      Recordset1.MoveNext()
    Wend
    %>
        )
        &lt;- Valid user names <br>
        <span class="style2">*Type name then press tab to switch focus </span></p>
      <p>Email 
        <input name="email" type="text" id="email" value="">
    </p>
    </form>
    </body>
    </html>
    <%
    Recordset1.Close()
    Set Recordset1 = Nothing
    %>
    Code:
    <!--#include file="db.asp" -->
    <%
    Dim email__MMColParam
    email__MMColParam = "1"
    If (Request.QueryString("name") <> "") Then 
      email__MMColParam = Request.QueryString("name")
    End If
    
    Dim email
    Dim email_numRows
    
    Set email = Server.CreateObject("ADODB.Recordset")
    email.ActiveConnection = conn
    email.Source = "SELECT user_email FROM ajax_user WHERE user_name = '" + Replace(email__MMColParam, "'", "''") + "'"
    email.CursorType = 0
    email.CursorLocation = 2
    email.LockType = 1
    email.Open()
    
    email_numRows = 0
    
    If Not email.EOF Or Not email.BOF Then
     Response.Write(email.Fields.Item("user_email").Value)
    Else 
    	Response.Write("")
    End If ' end Not email.EOF Or NOT email.BOF
    
    email.Close()
    Set email = Nothing
    %>
    http://computer-helpforum.com/asp/aj...ulate_form.asp

  • #5
    New Coder
    Join Date
    Feb 2006
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    my database name:supplier_head
    it contains:supplier_name, supplier_code

    my asp form:
    Supplier Code:
    <input name="suppliercode" type="text" id="suppliercode">
    Supplier Name:
    <input type="text" id="textname" name="suppliername">

    so, my actual problem is:
    when i enter or key in the supplier code value, supplier name will appear at the next textbox (suppliername) which the value will be display based on value i enter on supplier code...

    so, what is the best way can i do to make this thing happen...

  • #6
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just change the query to suit from the code I posted.

  • #7
    New Coder
    Join Date
    Feb 2006
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i've tried your coding but its does not fullfill what actually i want.
    actually, when i key in the supplier code, the supplier name will automatically be displayed based on the value of supplier code. there is no any submit button. just key in the supplier code and the supplier name display

  • #8
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The code I posted is an example of the methods that you need to use.

    You need to change the code to suit. It's obvisouly not going to work if you try to use that exact coding.

  • #9
    New to the CF scene
    Join Date
    Mar 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sample code

    Hi Degsy. Is the sample code that you provided all that I would need to make this work? What is the include for the db.asp? I checked out your sample page from the link provided and this will do exactly what I am looking for, I just need a little help with all of the pieces.

    Thanks!
    Rob

  • #10
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The db file is just my external file for connecting to the database.

    Once you have your connection made then the things that you need to change would be the queries and quesrystrings to extract the correct data.

  • #11
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    http://computer-helpforum.com/asp/as...ulate_form.asp

    See attachment for full coding.
    Attached Files Attached Files
    Last edited by degsy; 03-21-2006 at 04:25 PM.

  • #12
    New to the CF scene
    Join Date
    Mar 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    nevermind
    Last edited by flippy; 03-31-2006 at 05:27 AM.

  • #13
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is there is way that we can write code in Visual basic! Is like click one button on IE toolbar then automatic fill in.

    Does anyone have that information or know how to write that!

  • #14
    New Coder
    Join Date
    Feb 2006
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help me..

    Dim email__MMColParam
    email__MMColParam = "1"
    If (Request.QueryString("name") <> "") Then
    email__MMColParam = Request.QueryString("name")
    End If

    Dim email
    Dim email_numRows

    Set email = Server.CreateObject("ADODB.Recordset")
    email.ActiveConnection = conn
    email.Source = "SELECT user_email FROM ajax_user WHERE user_name = '" + Replace(email__MMColParam, "'", "''") + "'"
    email.CursorType = 0
    email.CursorLocation = 2
    email.LockType = 1
    email.Open()
    using the above code, you retrieve the user_email based on 1 condition that is user_name.what is the necessary code if I want to display the user_email based on 2 condition for example user_name and branch_name. The user only need to enter the user_name but it will compare both condition (user_name and branch_name)...

  • #15
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use standard SQL
    Code:
    sql="SELECT * FROM table WHERE field1 = '" & var1 & "' AND field2 = '" & var2 & "'"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •