Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP!! dropdown box population

Status
Not open for further replies.

tuam1234

Technical User
Feb 6, 2004
52
IE
could somebody please help me!

i have 2 popdown boxes: adminName + adminPassword, that i want to populate using the database table admin with the 2 fields adminName + adminPassword.

problem is, only the password dropdown box is being populated. the code to populate the name is been ignored.. why???

any suggestions greatly appreciated!
<% @LANGUAGE = VBSCRIPT %>
<% Option Explicit %>
<%'admin2.asp %>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional //EN">
<HTML>

'DATABASE CONNECTION

<%
Dim connection
Dim check
Dim loginData
Dim insert
Dim query

Set connection = Server.CreateObject("ADODB.Connection")
connection.Mode = 3
connection.Open("admin")

Set loginData = Server.CreateObject("ADODB.RecordSet")

'RETRIEVING NAME AND PASSWORD FROM DATABASE TABLE ADMIN

check= "SELECT adminName, adminPassword FROM admin"
Call loginData.Open(check,connection)
On Error Resume Next
%>

<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional //EN">
<HTML>

<HEAD>
<TITLE> Choosen Prices</TITLE>
<link rel="stylesheet" href="../../../xml%20fligts/style.css" type="text/css">
</HEAD>

<BODY BGCOLOR = "#FFFF99" class="stylesheet1">


<title>Test Form</title>

</head>
<br>

<form method="post" name="formname" action="../../adminOptions.asp" onSubmit="return checksubmit()">
<TABLE>
</TABLE>
</FORM>

'CREATING PASSWORD DROPDOWN BOX

<tr><td>
Password:
<TD><select name="adminPassword">
<option value="noSelection">Select Your Password
<%
If Request.Cookies ("adminPassword")<>"" Then
Call Returning()
Else
Call NewUser()
End If
%>
</select>
<br><br>

'CREATING NAME DROPDOWN BOX

Login Name:
<TD><select name="adminName">
<option value="noSelection">Select Your Name
<%
If Request.Cookies ("adminName")<>"" Then
Call BuildReturning()
Else
Call BuildNewUser()
End If
%>
</select>

<br><br>

<input type="submit" name="submitbtn" value="Submit">
<input type="reset" value="Clear">
</form>

</body>
</html>

'RETRIEVING AND REURNING PASSWORD

<%
Sub Returning()
Dim found

found = False
While Not loginData.EOF
%> <OPTION
<%
If(Not found) Then

If Request.Cookies("adminPassword")_
= loginData("adminPassword")_
Then
Call Response.Write("SELECTED")
found = True
End If
End If
%>
Value = "<%=loginData("adminPassword") %>">
<%=loginData ("adminPassword")%>
<% Call loginData.MoveNext()
Wend
End Sub

Sub NewUser()
While Not loginData.EOF
%> <OPTION VALUE = "<%=loginData("adminPassword")%>">
<%=loginData ("adminPassword")%>
<% Call loginData.MoveNext()
Wend
End Sub
%>

'RETRIEVING AND RETURNING NAME

<%
Sub BuildReturning()
Dim found

found = False
While Not loginData.EOF
%> <OPTION
<%
If(Not found) Then

If Request.Cookies("adminName")_
= loginData("adminName")_
Then
Call Response.Write("SELECTED")
found = True
End If
End If
%>
Value = "<%=loginData("adminName") %>">
<%=loginData ("adminName")%>
<% Call loginData.MoveNext()
Wend
End Sub

Sub BuildNewUser()
While Not loginData.EOF
%> <OPTION VALUE = "<%=loginData("adminName")%>">
<%=loginData ("adminName")%>

<% Call loginData.MoveNext()
Wend
End Sub
%>
</td></tr>
<br><br><br>



 



add this line where you have this:


'CREATING NAME DROPDOWN BOX
<%
loginData.MoveFirst()
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top