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!

populating 2 popdown boxes using database details

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!

<%
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")

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

<H1><U>High Flyers</U> </H1><BR><BR>
<H2>Please Enter Your Credit Card Details </H2><BR><BR>
<H2></H2>All the field below MUST be completed.<BR>
<title>Test Form</title>

</head>
<br>

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

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

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

<%
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
%>
 
Your looping to the end of your RecordSet in all of the functions. This means that after you call the function one time the recordset is then pointing to the last record + 1 (EOF) and therfor any further loops will not actually occur (If rs.EOF returns true, server doesn't enter loop).

The solution would be to move the cursor back to the front of the recordset again, either at the begining of each call or at the end of each call. Basically this means just adding a loginData.MoveFirst method to one he suggested locaions in each function.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
thanks a million tarwn, that did the trick.

thanks again :-D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top