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, prob displaying database info!!!!

Status
Not open for further replies.

tuam1234

Technical User
Feb 6, 2004
52
IE
hey guys, i no its st pats day but can someone please help me!!!!!!!

i have an asp that populates a dropdown box with destinations. i chose one of the destinations from the dropdown box. this leads to another asp where i want my choice and the database information to be displayed on the 2nd asp.

problem is,itl display the 2nd asp but it wont display the chosen destination...

the code is:

1st asp........................

<%
Dim connection
Dim check
Dim check2
Dim check3
Dim check4
Dim logindata
Dim loginData2
Dim loginData3
Dim loginData4
Dim insert
Dim query

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

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

check= "SELECT DISTINCT Destination FROM MockDest"
Call logindata.Open(check,connection)


On Error Resume Next
%>

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

<HEAD>
<TITLE> Updatable Choose</TITLE>
<link rel="stylesheet" href="file:///C|/Inetpub/Mhaire%20 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>
<script language="Javascript">

function checksubmit()
{
if ((document.formname.qty.value == "")|| (isNaN(document.formname.qty.value)) )
{
alert("Please enter a quantity value");
document.formname.qty.focus();
return false
}


return true
}
</script>
</head>
<body onLoad="document.formname.qty.focus()"
<br>

<TABLE>
</TABLE>
Wend

<tr><td>
destination:
<TD><select name="Destination">
<%
If Request.Cookies ("Destination")<>"" Then
Call Returning()
Else
Call NewUser()
End If
%>
</select>

<br><br>
</form>



<%
Sub Returning()
Dim found

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

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

Sub NewUser()
While Not loginData.EOF
%> <OPTION VALUE = "<%=loginData("Destination")%>">
<%=loginData ("Destination")%>
<% Call logindata.MoveNext()
Wend
Call loginData.MoveFirst()

End Sub
%>

2nd asp.................

<%

'Dimension variables
Dim connection 'Holds the Database Connection Object
Dim check 'Holds the recordset for the records in the database
Dim logindata 'Holds the SQL query for the database
Dim totalCost
Dim quantity
Dim cost
Dim arrtime
Dim destination
Dim deptime
Dim leaving
Dim flightID
Dim total



Set connection = Server.CreateObject("ADODB.Connection")

Call connection.Open ("auction1")

check = "SELECT Destination FROM MockDest WHERE Destination = '"_
& Request ( "Destination") & "'"


Set logindata = Server.CreateObject("ADODB.Recordset")

Call logindata.Open (check , connection)
On Error Resume Next

if Request ("Destination") = logindata("Destination") Then

totalCost = logindata("Destination")%>

<th> The total cost of the flights is: </th><br>

<%Response.Write(totalCost)
%>
<%end if
%>

i would be extremely gratful for any replies!!!!!!!
 
Have you done a response.write or something to verify that when the 2nd asp loads request("destination") has a value?

- VB Rookie
 
where is this code?
Code:
<FORM ACTION="page2.asp" METHOD="POST" NAME="formname">

Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
to answer VB Rookie first:

ya i tried that and i get
"error type:
ADODB.Field (0x800A0BCD)
Either BOF or EOF if True, or the current record has been deleted. Requested operation requires a current record."

tony iv the line of code wrote in at the base of the 1st asp after the final End Sub like this:

<form method="post" name="formname" action="page2.asp" onSubmit="return checksubmit()">

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


 
Ok well that's definitely a problem. If you're getting an error when trying to retrieve the destination value on the 2nd asp that's likely why its coming back blank.

Alright help me to understand a couple of things. When exactly does the redirect to the 2nd asp occur? When the user selects something from the destination drop-down? I didn't see a submit button in your code (I may have overlooked it).

If the redirection occurs on the onchange of the destination drop-down then you can pass the selected value utilizing Javascript to the 2nd asp in the URL and pull it out of the querystring there.

Let me know if this makes sense or not.

- VB Rookie
 
thanks a million to both of ye for replying to me. it actually was a case of the form tag been in the wrong place..

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

Part and Inventory Search

Sponsor

Back
Top