Indigo Rose Software
  #1  
Old 06-12-2005
ianhull ianhull is offline
Forum Member
 
Join Date: Jul 2004
Posts: 313
Anyone please help with asp

Can anyone please help me with this asp sample?
I know that many of you are into php but I recall one of you helping me with asp before.

I have a selection box where I can choose country, after I select the country a table is created with 3 columns from the database

I then want to post the record from column 1 to a processform.asp "which works fine" this column is called companyname.

Here is what I have

<html>
<body>

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb"))

set rs=Server.CreateObject("ADODB.recordset")
sql="SELECT DISTINCT Country FROM Customers ORDER BY Country"
rs.Open sql,conn

country=request.form("country")

%>

<form method="post">
Choose Country <select name="country">
<% do until rs.EOF
response.write("<option")
if rs.fields("country")=country then
response.write(" selected")
end if
response.write(">")
response.write(rs.fields("Country"))
rs.MoveNext
loop
rs.Close
set rs=Nothing %>
</select>
<input type="submit" value="Show customers">
</form>

<%
if country<>"" then
sql="SELECT Companyname,Contactname,Country FROM Customers WHERE country='" & country & "'"
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn
%>
<table width="100%" cellspacing="0" cellpadding="2" border="1">
<tr>
<th>Companyname</th>
<th>Contactname</th>
<th>Country</th>
</tr>
<%
do until rs.EOF
response.write("<tr>")
response.write("<td>" & rs.fields("companyname") & "</td>") \\I want to post this to the next page
response.write("<td>" & rs.fields("contactname") & "</td>")
response.write("<td>" & rs.fields("country") & "</td>")
response.write("</tr>")
rs.MoveNext
loop
rs.close
conn.Close
set rs=Nothing
set conn=Nothing%>
</table>
<% end if %>

</body>
</html>

If anyone can help with this it will be very much appreciated.

Thanks Guys.
Reply With Quote
  #2  
Old 06-13-2005
Philo Philo is offline
Forum Member
 
Join Date: Feb 2004
Location: Cardiff
Posts: 78
Im a little bit confused as to what you want to do so may have the worng end of the stick.

If you want to send the value from this page to the next you could include it inside your form.

<input type="text" value="<%=rs.fields("companyname")%>">

You could also do

<input type="hidden" value="<%=rs.fields("companyname")%>">

If you wanted to pass a value but not display it to the user.
Reply With Quote
  #3  
Old 06-13-2005
Philo Philo is offline
Forum Member
 
Join Date: Feb 2004
Location: Cardiff
Posts: 78
sorry that should be:

<input type="text" name="a_name" value="<%=rs.fields("companyname")%>">
Reply With Quote
  #4  
Old 06-13-2005
ianhull ianhull is offline
Forum Member
 
Join Date: Jul 2004
Posts: 313
Thanks Philo,

It does not sem to work but I will keep trying, I appreciate your help.

Reply With Quote
  #5  
Old 06-14-2005
Philo Philo is offline
Forum Member
 
Join Date: Feb 2004
Location: Cardiff
Posts: 78
Ensure that line is within your form tags

Alternatively

Have you tried session variables?

Try Session("companyname") = rs.fields("companyname")

Then you can return it on any future pages by doing

Dim companyname
companyname = Session("companyname")

Have a look here for more info
http://www.w3schools.com/asp/asp_sessions.asp
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check if allowed to update using ASP and Trueupdate nickw TrueUpdate 1.0 4 06-20-2003 02:13 PM
ASP Web Get/Post greenace Setup Factory 6.0 9 06-07-2003 12:01 AM
Submit to web ASP kaylward Setup Factory 6.0 1 11-30-2002 08:15 PM
True Update from ASP day10 TrueUpdate 1.0 3 08-08-2002 04:07 PM


All times are GMT -6. The time now is 10:20 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software