Forum Moderators: open

Message Too Old, No Replies

How do I get Information from one page to another

Using a FORM

         

Andrew Thomas

1:15 pm on Apr 17, 2003 (gmt 0)

10+ Year Member



Ok - I have a form (see code below) which allows you to select options or check boxes. I need these selections to be viewable in results.asp. The problem is, i dont know where I have to start or what to do in order to get these results displayed?

A snippet of the code is

<input type="checkbox" name="checkbox3" value="<%= (rs_SEAD.Fields.Item("tblProduct_Akhter Code").Value)%>">

I would like tblProduct_Akhter Code displayed in the results page, but also the title and price too. Do i need to modify this code aswell?

Any ideas, thanx
I can send the URL (IP address if required)

<form name="form1" method="post" action="results.asp">
<blockquote>
<% If Not rs_AKHA.EOF Or Not rs_AKHA.BOF Then %>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr bgcolor="#CCCCCC" class="maintext">
<td colspan="5" class="subproductheading"><div align="center">Choose
your Processor</div>
</td>
</tr>
<%
While ((Repeat2__numRows <> 0) AND (NOT rs_AKHA.EOF))
%>
<tr class="maintext">
<td width="19%">
<div align="center">
<input type="radio" name="radiobutton" value="<%= (rs_AKHA.Fields.Item("tblProduct_Akhter Code").Value)%>">
</div>
</td>
<td width="8%"><%=(rs_AKHA.Fields.Item("tblProduct_Akhter Code").Value)%></td>
<td width="6%">&nbsp;</td>
<td width="53%"><%=(rs_AKHA.Fields.Item("Title").Value)%></td>
<td width="13%"><%=(rs_AKHA.Fields.Item("Prem Price").Value)%></td>
</tr>
<%
Repeat2__index=Repeat2__index+1
Repeat2__numRows=Repeat2__numRows-1
rs_AKHA.MoveNext()
Wend
%>
</table>
<br>
<% End If ' end Not rs_AKHA.EOF Or NOT rs_AKHA.BOF %>
</blockquote>
<input type="submit" name="Submit" value="Submit">
</p>
</form>

txbakers

1:22 pm on Apr 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When you click a "submit" button, the information in form elements is sent via either the POST or GET method to the server.

The receiving page can read those requests using the "Request" method of ASP:

If a parameter (form field) is called "product", I would get the value as follows:

dim reqProd
reqProd = request("product")

Then I can use the reqProd variable anywhere in my program.

Read up on ASP at www.w3schools.com. Lots of good information there - easy to understand too!

sullen

1:26 pm on Apr 17, 2003 (gmt 0)

10+ Year Member



Um, think I could have mis-read your post here, but why don't you use:

[checkbox3text]: <%= request.form("checkbox3") %>

Right I see someone has beaten me.

But best to use the POST method rather than GET (saves messy querystrings) The form tag should read

<FORM ACTION="whatever.asp" METHOD="post">

Andrew Thomas

2:00 pm on Apr 17, 2003 (gmt 0)

10+ Year Member



Ok thanks to you both..

I would also like the title and price too displayed on the results page. At the moment i have just called it from a recordset, do i need to put this in a text field aswell, in order to transfer it across to results.asp?

If so, is there a way to may the text field box look like normal text (hide the box)

thanks

sullen

2:33 pm on Apr 17, 2003 (gmt 0)

10+ Year Member



It's up to you really. It would save server power a bit if you write the title etc to a text box if you're doing a database look-up anyway on that page, but as long as you're closing connections properly it shouldn't be a problem to have a lookup on both pages.

You can hide the text field either with CSS (although this doesn't work in Netscape), or you can simply write the details to the page as you are doing and then have a hidden form field -

<INPUT TYPE="hidden" NAME="Title" VALUE="<%= rs_AKHA.Fields.Item("Title").Value %>">

You can place hidden form fields anywhere on the page and they won't display to the user.

graywolf

3:15 pm on Apr 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Be careful pulling the price from the form and not the database. A clever person could make a form that submits to you using their own price.

Andrew Thomas

3:25 pm on Apr 17, 2003 (gmt 0)

10+ Year Member



I get the feeling im doing this the wrong way?

I have rows of :-

[checkbox] Item Code Title Price

(coming from my database via 4 different fields and one table)

I want it so if the checkbox is checked, all the data (Code, title and price) is selected and shown on the results page

(from this i will add up the prices and produce a total etc)

Is it best to capture the product code only, and then use SQL to read the database to retrieve the title and price to be displayed on the results page?

If so what would the SQL look like. (im getting confused)

If you want to see my effort i can email the URL so you get a better understanding of the problem

Or any other ideas please let me know

graywolf

3:34 pm on Apr 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



request the item (by sku, id or whatever you are using to identify the item) and request the quantity.

Make sure you error handle for bad skus, id's and quantities, some knucklehead will try to put in a qty. of "B" sooner or later.

You should always get the price from the database. As far as the title and any other information thats up to you to decide how mission critical it is.

Andrew Thomas

10:50 am on Apr 22, 2003 (gmt 0)

10+ Year Member



Ok, to stop people from changing the prices i will call the Akhter Product code from the products.asp page, but gather the title and price from the database

products.asp page contains:-

<input type="checkbox" name="checkbox3" value="<%= (rs_SEAD.Fields.Item("tblProduct_Akhter Code").Value)%>">

Results.asp contains:-

Dim rs_selection__MMColParam
rs_selection__MMColParam = "1"
If (Request.Form("checkbox3") <> "") Then
rs_selection__MMColParam = Request.Form("checkbox3")
End If

rs_selection.Source = "SELECT * FROM [Query - Product Compontent join] WHERE [tblProduct_Akhter Code] = '" + Replace(rs_selection__MMColParam, "'", "''") + "'"

This only works if i select one check box, if i select to or more check boxes no errors appear no results are shown?

Ive have put a reapeat region in using dreamweaver MX, but this did not solve the problem.

Any help?

Thanks