Could someone help with my ASP code below

Discussion in 'ASP General' started by MrHelpMe, Feb 17, 2008.

  1. MrHelpMe

    MrHelpMe Guest

    Hello all,

    I have tried other forums and they have been nice enough to help until
    a point. I have the following code below and it is doing the
    following. Next to an input box I will have something saying choose
    from list.(This is working on Test.asp page). When I click on the
    text, a popup box opens and there are 2 fields. Once called Partial
    Search where a user can start typing his search info. and a
    dropdownlist (I don't care what element is used). What it should do
    is when the user starts typing a partial search the element below (in
    this case the dropdownlist) should start to move or highlight all the
    values that equal the partial search (like a lookup table). <b>THIS IS
    NOT WORKING</b>. The dropdownlist is querying active directory
    (working perfectly) with too many values so this is why I need the
    partial search. Then when I click Select (After I found the value I
    was looking for), the input box(next to the Choose from list Text)
    should be populated with the result of the search term<b>(Also not
    working)</b>. Let me know if that makes sense. Thanks.

    Test.asp
    Code:
    <%@ Language="VBScript" %>
    <%OPTION EXPLICIT%>
    <%
    'Declare variables
    Dim objConnection
    Dim objCommand
    Dim objRecordSet
    
    %>
    <HTML>
    <HEAD>
    <TITLE>test</TITLE>
    
    <script type="text/javascript">
    <!--
    var originalvariable
    
    function popup(mylink, windowname){
    href=mylink.href;
    window.open(href, windowname,
    'width=360,height=260,scrollbars=no,top=200,left=1    95');
    return false;
    }
    
    document.form1.target = name;
    document.form1.action = "ProcessSubmit.asp";
    document.form1.submit();
    }
    //-->
    </script>
    </HEAD>
    
    <TABLE height="0" width="100%" bgcolor="336699" border="0"
    cellspacing="0" cellpadding = "0" align="center">
    <FORM name="form1" action="" method="post">
    <TR>
    <TD align="Center"><FONT color="#FF0000">* </FONT><font size = "2"
    color = "Black"><B> Required Information</B></font></TD>
    </TR>
    </TABLE>
    <BR>
    <TABLE border="1" cellspacing="0" align="center" bgcolor="336699">
    <TR>
    <TD><DIV align="left"><font color="#FF0000">* </font><FONT
    color="White"><B>Name:</B></FONT></TD>
    <TD><input type="text" name="username">&nbsp;<A HREF="test1.asp"
    onClick="return popup(this, 'UserPicker');"><font color="white">Choose
    from List</font></A></td>
    </tr>
    <tr>
    <td colspan="2" align="center"><input type="button" name="Send"
    value="Submit">
    </td>
    </TR>
    </TABLE>
    </FORM>
    </BODY>
    </HTML>
    
    This is the recieving page test1.asp

    Code:
    <html>
    <head>
    <TITLE>User List</TITLE>
    <script type="text/javascript">
    <!--
    function dosearch(){
    document.pickform.action="hgfgf";
    document.pickform.criteria=document.partial.value;
    document.pickform.submit();
    }
    //-->
    
    </script>
    </head>
    <body>
    <%
    If Request.Form("action") <> "add_user" Then
    %>
    <TABLE height="0" width="100%" bgcolor="336699" border="0"
    cellspacing="0" cellpadding = "0" align="center">
    <form name="pickform" action="test1.asp" method="post">
    <table border="0">
    <tr><td colspan="2"><b>Select User From list:</b></td></tr>
    <tr><td colspan="2">&nbsp;</td></tr>
    <tr><td colspan="2">&nbsp;</td></tr>
    <tr><td>Partial Search&nbsp;</td><td><input type="text" name="partial"
    onchange="dosearch()"></tr>
    <tr><td><input type="hidden" name="criteria"></td></tr>
    <tr><td colspan="2">
    <input type="hidden" name="action" value="add_user" />
    <%Dim testvar%>
    <%testvar= request.form("partial")%>
    <%
    Set objConnection = CreateObject("ADODB.Connection")
    Set objCommand =   CreateObject("ADODB.Command")
    
    objConnection.Provider = "ADsDSOObject"
    objConnection.Properties("User ID") = "Hidden"
    objConnection.Properties("Password") = "Hidden"
    
    objConnection.Open "Active Directory Provider"
    Set objCommand.ActiveConnection = objConnection
    
    objCommand.Properties("Page Size") = 10000
    objCommand.Properties("Timeout") = 50
    objCommand.Properties("Cache Results") = False
    
    objCommand.CommandText = _
    
    "SELECT Name FROM 'LDAPserver' where Field1 = 3 and field2 <> 111
    ORDER BY NAME"
    
    If Request.Form("criteria") <> "" Then objCommand.CommandText = _
    "SELECT Name FROM 'LDAPserver' where Field1 = 3 and field2 <> 111 and
    name like ='" & TestVar & "'"
    
    Set objRecordSet = objCommand.Execute
    %>
    <select size="1" name="D1">
    <option selected value="ZZZZZZ">Please Select</option>
    <%
    If ((objRecordSet.BOF <> True) And (objRecordSet.EOF <> True)) Then
    'Loop through all of the records that have been found
    While Not objRecordSet.EOF%>
    <option value="<%=Trim(objRecordSet("Name"))%>"><
    %=Trim(objRecordSet("Name"))%></option><%
    objRecordSet.movenext
    Wend
    End If
    %>
    </select>
    </td></tr>
    <%
    'objRecordSet.Close
    'oConn.Close
    %>
    <tr>
    <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
    <td colspan="2"><input type="submit" value="Select">&nbsp;
    <input type="button" value="Close" onclick="window.close()">&nbsp;
    </td>
    </tr>
    </table>
    </form>
    <%
    Else
    If strSelection = "ZZZZZZ" Then
    response.write "<script language='javascript'>window.close();</
    script>"
    Else
    response.write"<script
    language='javascript'>window.opener.document.form1.username.value="""
    & strSelection & """</script>"
    response.write "<script language='javascript'>window.close();</
    script>"
    End If
    End If
    %>
    </TABLE>
    </FORM>
    </BODY>
    </HTML>
    
     
    MrHelpMe, Feb 17, 2008
    #1
    1. Advertising

  2. MrHelpMe

    Evertjan. Guest

    MrHelpMe wrote on 17 feb 2008 in microsoft.public.inetserver.asp.general:

    > Test.asp


    The rest of this page does not contain any ASP,
    do why declare the below thayt is not used?

    ===================================
    > <%@ Language="VBScript" %>
    > <%OPTION EXPLICIT%>
    > <%
    > 'Declare variables
    > Dim objConnection
    > Dim objCommand
    > Dim objRecordSet
    >
    > %>

    =========================

    > <HTML>
    > <HEAD>
    > <TITLE>test</TITLE>
    >
    > <script type="text/javascript">
    > <!--


    last century coding to use this: <!--
    leave it out!

    > var originalvariable


    This clientside variable is not used.

    >
    > function popup(mylink, windowname){
    > href=mylink.href;
    > window.open(href, windowname,
    > 'width=360,height=260,scrollbars=no,top=200,left=1 95');
    > return false;
    >}


    The below code does not belong to anything, so will give an error,
    please report all errors with errortext and linenumber.

    ==========================
    > document.form1.target = name;
    > document.form1.action = "ProcessSubmit.asp";
    > document.form1.submit();
    >}

    ==========================

    > //-->


    See above.

    > </script>
    > </HEAD>
    >
    > <TABLE height="0" width="100%" bgcolor="336699" border="0"
    > cellspacing="0" cellpadding = "0" align="center">
    > <FORM name="form1" action="" method="post">
    > <TR>
    > <TD align="Center"><FONT color="#FF0000">* </FONT><font size = "2"
    > color = "Black"><B> Required Information</B></font></TD>
    > </TR>
    > </TABLE>


    Why use a table here?
    Why not use css?
    Why starting a <form> in the middle of a table where it is not used yet?

    > <BR>
    > <TABLE border="1" cellspacing="0" align="center" bgcolor="336699">
    > <TR>
    > <TD><DIV align="left"><font color="#FF0000">* </font><FONT
    > color="White"><B>Name:</B></FONT></TD>
    > <TD>


    > <input type="text" name="username">&nbsp;
    > <A HREF="test1.asp" onClick="return popup(this, 'UserPicker');">
    > <font color="white">Choose > from List</font></A></td>


    Why use a anchor here, if you only use the onclick??
    All those antique <font> declarations are a terrible sight,
    use css styles!

    > </tr>
    > <tr>
    > <td colspan="2" align="center">
    > <input type="button" name="Send" value="Submit">
    > </td>
    > </TR>
    > </TABLE>
    > </FORM>
    > </BODY>
    > </HTML>


    Seems to me you have a lot of work to do on this file,
    before even touching the next one.

    As most of it is not ASP related, please ask in a clientside NG.


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Feb 17, 2008
    #2
    1. Advertising

  3. MrHelpMe

    s_m_b Guest

    MrHelpMe <> wrote in news:f4a1ab76-4944-4c1b-b3ff-
    :

    Why not do this via Ajax? Most of what you're trying to do is client side
    anyway.


    > Hello all,
    >
    > I have tried other forums and they have been nice enough to help until
    > a point. I have the following code below and it is doing the
    > following. Next to an input box I will have something saying choose
    > from list.(This is working on Test.asp page). When I click on the
    > text, a popup box opens and there are 2 fields. Once called Partial
    > Search where a user can start typing his search info. and a
    > dropdownlist (I don't care what element is used). What it should do
    > is when the user starts typing a partial search the element below (in
    > this case the dropdownlist) should start to move or highlight all the
    > values that equal the partial search (like a lookup table). <b>THIS IS
    > NOT WORKING</b>. The dropdownlist is querying active directory
    > (working perfectly) with too many values so this is why I need the
    > partial search. Then when I click Select (After I found the value I
    > was looking for), the input box(next to the Choose from list Text)
    > should be populated with the result of the search term<b>(Also not
    > working)</b>. Let me know if that makes sense. Thanks.
    >
    > Test.asp
    >
    Code:
    > <%@ Language="VBScript" %>
    > <%OPTION EXPLICIT%>
    > <%
    > 'Declare variables
    > Dim objConnection
    > Dim objCommand
    > Dim objRecordSet
    >
    > %>
    > <HTML>
    > <HEAD>
    > <TITLE>test</TITLE>
    >
    > <script type="text/javascript">
    > <!--
    > var originalvariable
    >
    > function popup(mylink, windowname){
    > href=mylink.href;
    > window.open(href, windowname,
    > 'width=360,height=260,scrollbars=no,top=200,left=1    95');
    > return false;
    > }
    >
    > document.form1.target = name;
    > document.form1.action = "ProcessSubmit.asp";
    > document.form1.submit();
    > }
    > //-->
    > </script>
    > </HEAD>
    >
    > <TABLE height="0" width="100%" bgcolor="336699" border="0"
    > cellspacing="0" cellpadding = "0" align="center">
    > <FORM name="form1" action="" method="post">
    > <TR>
    >  <TD align="Center"><FONT color="#FF0000">* </FONT><font size = "2"
    > color = "Black"><B> Required Information</B></font></TD>
    > </TR>
    > </TABLE>
    > <BR>
    > <TABLE border="1" cellspacing="0" align="center" bgcolor="336699">
    > <TR>
    > <TD><DIV align="left"><font color="#FF0000">* </font><FONT
    > color="White"><B>Name:</B></FONT></TD>
    > <TD><input type="text" name="username">&nbsp;<A HREF="test1.asp"
    > onClick="return popup(this, 'UserPicker');"><font color="white">Choose
    > from List</font></A></td>
    > </tr>
    > <tr>
    > <td colspan="2" align="center"><input type="button" name="Send"
    > value="Submit">
    > </td>
    > </TR>
    > </TABLE>
    > </FORM>
    > </BODY>
    > </HTML>
    > 
    >
    > This is the recieving page test1.asp
    >
    >
    Code:
    > <html>
    > <head>
    > <TITLE>User List</TITLE>
    > <script type="text/javascript">
    > <!--
    > function dosearch(){
    > document.pickform.action="hgfgf";
    > document.pickform.criteria=document.partial.value;
    > document.pickform.submit();
    > }
    > //-->
    >
    > </script>
    > </head>
    > <body>
    > <%
    > If Request.Form("action") <> "add_user" Then
    > %>
    > <TABLE height="0" width="100%" bgcolor="336699" border="0"
    > cellspacing="0" cellpadding = "0" align="center">
    > <form name="pickform" action="test1.asp" method="post">
    > <table border="0">
    > <tr><td colspan="2"><b>Select User From list:</b></td></tr>
    > <tr><td colspan="2">&nbsp;</td></tr>
    > <tr><td colspan="2">&nbsp;</td></tr>
    > <tr><td>Partial Search&nbsp;</td><td><input type="text" name="partial"
    > onchange="dosearch()"></tr>
    > <tr><td><input type="hidden" name="criteria"></td></tr>
    > <tr><td colspan="2">
    > <input type="hidden" name="action" value="add_user" />
    > <%Dim testvar%>
    > <%testvar= request.form("partial")%>
    > <%
    > Set objConnection = CreateObject("ADODB.Connection")
    > Set objCommand =   CreateObject("ADODB.Command")
    >
    > objConnection.Provider = "ADsDSOObject"
    > objConnection.Properties("User ID") = "Hidden"
    > objConnection.Properties("Password") = "Hidden"
    >
    > objConnection.Open "Active Directory Provider"
    > Set objCommand.ActiveConnection = objConnection
    >
    > objCommand.Properties("Page Size") = 10000
    > objCommand.Properties("Timeout") = 50
    > objCommand.Properties("Cache Results") = False
    >
    > objCommand.CommandText = _
    >
    > "SELECT Name FROM 'LDAPserver' where Field1 = 3 and field2 <> 111
    > ORDER BY NAME"
    >
    > If Request.Form("criteria") <> "" Then objCommand.CommandText = _
    > "SELECT Name FROM 'LDAPserver' where Field1 = 3 and field2 <> 111 and
    > name like ='" & TestVar & "'"
    >
    > Set objRecordSet = objCommand.Execute
    > %>
    > <select size="1" name="D1">
    > <option selected value="ZZZZZZ">Please Select</option>
    > <%
    > If ((objRecordSet.BOF <> True) And (objRecordSet.EOF <> True)) Then
    > 'Loop through all of the records that have been found
    > While Not objRecordSet.EOF%>
    > <option value="<%=Trim(objRecordSet("Name"))%>"><
    > %=Trim(objRecordSet("Name"))%></option><%
    > objRecordSet.movenext
    > Wend
    > End If
    > %>
    > </select>
    > </td></tr>
    > <%
    > 'objRecordSet.Close
    > 'oConn.Close
    > %>
    > <tr>
    > <td colspan="2">&nbsp;</td>
    > </tr>
    > <tr>
    > <td colspan="2"><input type="submit" value="Select">&nbsp;
    > <input type="button" value="Close" onclick="window.close()">&nbsp;
    > </td>
    > </tr>
    > </table>
    > </form>
    > <%
    > Else
    > If strSelection = "ZZZZZZ" Then
    > response.write "<script language='javascript'>window.close();</
    > script>"
    > Else
    > response.write"<script
    > language='javascript'>window.opener.document.form1.username.value="""
    > & strSelection & """</script>"
    > response.write "<script language='javascript'>window.close();</
    > script>"
    > End If
    > End If
    > %>
    > </TABLE>
    > </FORM>
    > </BODY>
    > </HTML>
    > 
    >
     
    s_m_b, Feb 22, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. 1111111111
    Replies:
    11
    Views:
    576
    Aguilar, James
    Jul 12, 2004
  2. Gactimus
    Replies:
    22
    Views:
    730
    jeffc
    Dec 15, 2004
  3. joshc
    Replies:
    14
    Views:
    787
    Keith Thompson
    Jan 14, 2005
  4. Caduceus
    Replies:
    5
    Views:
    131
    Tad McClellan
    Jan 23, 2007
  5. kiran
    Replies:
    12
    Views:
    1,128
    Scott Sauyet
    Dec 7, 2011
Loading...

Share This Page