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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Request a value from a form,

Status
Not open for further replies.

Beracosta

Programmer
Oct 25, 2000
47
SE
I have a problem. I'm programming a homepage in asp with VBScript and databases. And i also have a shopping basket on it. And now to my problem, i have a file, AddToBasket.asp, that puts the merchant in the basket and i call it with:

AddToBasket.asp?BasketID=...&MerchantID=...&Quantity=...

And my problem is: I want the value of a <input type=&quot;text&quot;>
to be the number that will be passed on with Quantity=...
but i can't solve this on my own... i want help!!! pls help me...
 
If I have understood you correctly then what you want to do is have Quantity set to the value stored in the input box on the page.
If this is correct here is what you do:

1. You set the method of the form to GET.

2. You create an iput box as follows:

Code:
   <INPUT type=&quot;text&quot; name=&quot;Quantity&quot;>

The use of GET in the form action sends the data via the querystring as you have described in your question. The querystring contains a name=value pair for every form element in your HTML form.

If this is not what you wanted/meant if you further clarify I will endevour to help further.

James :)

James Culshaw
jamesculshaw@active-data-solutions.co.uk
 
Thanx for the help... I will now also put the source here so u can help me even further...

This is the AddToBasket.asp file:

<%
Dim oCmd
Dim BasketID, MerchantID, Quantity
Dim strSQL

BasketID = Request(&quot;BasketID&quot;)
MerchantID = Request(&quot;MerchantID&quot;)
Quantity = Request(&quot;Quantity&quot;)

Set oCmd = Server.CreateObject(&quot;ADODB.Command&quot;)
With oCmd
.ActiveConnection = &quot;DSN=SYCENT;&quot;
strSQL = &quot;INSERT INTO BasketContent(BasketID, MerchantID, Quantity) VALUES(&quot; & BasketID & &quot;, &quot; & MerchantID & &quot;, &quot; & Quantity & &quot;)&quot;
.CommandText = strSQL
.Execute
Set .ActiveConnection = Nothing
End With

Set oCmd = Nothing
%>

and this is the ShowArt.asp file:

<html>
<head><title>Global Kockknivar</title></head>

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot; link=&quot;#008000&quot; vlink=&quot;#800000&quot; alink=&quot;#808000&quot;>
<%
Dim oRs
Dim strSQL
Set oRs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
With oRs
.ActiveConnection = &quot;DSN=SYCENT;&quot;
'DB Hintar
.CursorLocation = 3
.CursorType = 3
.LockType = 4
strSQL = &quot;SELECT * FROM Merchants &quot; & _
&quot;WHERE Id = &quot; & Request(&quot;ID&quot;)

.Open strSQL
Set .ActiveConnection = Nothing



Response.Write &quot;<div align=&quot;&quot;center&quot;&quot;><font size=&quot;&quot;7&quot;&quot; FACE=&quot;&quot;Verdana, Arial&quot;&quot; COLOR=&quot;&quot;#D61303&quot;&quot;>&quot; & oRs(&quot;Name&quot;).Value & &quot;</font><br>&quot;
Response.Write &quot;<div align=&quot;&quot;center&quot;&quot;><img src=&quot; & oRs(&quot;Picture&quot;).Value & &quot; ALT=&quot; & oRs(&quot;Name&quot;).Value & &quot; BORDER=&quot;&quot;0&quot;&quot;></div><br>&quot;
Response.Write &quot;<FORM NAME=&quot;&quot;BasketForm&quot;&quot;&quot;><table border=&quot;&quot;1&quot;&quot; ALIGN=&quot;&quot;RIGHT&quot;&quot;>&quot;
Response.Write &quot;<tr><td><b><div align=&quot;&quot;center&quot;&quot;>Pris inkl. moms</div></b></td><td><b><div align=&quot;&quot;center&quot;&quot;>Antal</div></b></td>&quot;
Response.Write &quot;<td><b><div align=&quot;&quot;center&quot;&quot;>Beställ</div></b></td></tr>&quot;
Response.Write &quot;<tr><td><div align=&quot;&quot;center&quot;&quot;><b>&quot; & oRs(&quot;Pris&quot;).Value & &quot;kr</b></div></td>&quot;
Response.Write &quot;<td><div align=&quot;&quot;center&quot;&quot;><b><input type=&quot;&quot;text&quot;&quot; size=&quot;&quot;3&quot;&quot; name=&quot;&quot;Quantity&quot;&quot; value=&quot;&quot;1&quot;&quot;></b></td>&quot;
Response.Write &quot;<a href=&quot;&quot;AddToBasket.asp?MerchantID=&quot; & oRs(&quot;Id&quot;).Value & &quot;&BasketID=11&Quantity=&quot; & Request.Form(&quot;Antal&quot;) & &quot;&quot;&quot;>&quot;
Response.Write &quot;<td><INPUT TYPE=&quot;&quot;SUBMIT&quot;&quot; VALUE=&quot;&quot;Lägg till&quot;&quot;></td></tr></table></form><br>&quot;
Response.Write &quot;<div align=&quot;&quot;center&quot;&quot;><font size=&quot;&quot;3&quot;&quot; face=&quot;&quot;Verdana, Arial&quot;&quot;><b>&quot; & oRs(&quot;Beskrivning&quot;) &&quot;</b></font></div>&quot;

.Close
End With
Set oRs = Nothing
%>


</body>
</html>

can u pls tell me how to rewrite my code to achive the goal:
To pass the value from the text box named Quantity to my AddToBasket.asp file? pls help me...
 
don't mind this any more... i solved it on my self with method = &quot;post&quot; and Request.Form *happy*
=) but thanx for all your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top