Could someone help with my ASP code below


M

MrHelpMe

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>
 
Ad

Advertisements

E

Evertjan.

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

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 said:
<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??
</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.
 
Ad

Advertisements

S

s_m_b

(e-mail address removed):

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top