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

I making a shopping cart

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
senaraio<br>user enters a part of a &quot;part number&quot; in a form on a an .asp page. A second .asp page returns a list of results in a table, this works great.<br>So I have a list of matching parts in a Table format from one to many parts returned.<br>One of the cells in the table is a submit button<br>Which is labeled &quot;Add to Cart&quot; so there is a button for every row in the table.<br>Now How can I get the part number from th eTable when they user presses say the tenth button down the list.<br>Or is there a better way fo doing it<br>Here is some of my code.<br>-----------------------<br>&lt;html&gt;&lt;head&gt;<br>&lt;TITLE&gt;Parts respond.asp&lt;/TITLE&gt;<br>&lt;/head&gt;<br><br>&lt;body bgcolor=&quot;#FFFFFF&quot;&gt;<br>&lt;br&gt;<br>&lt;br&gt;<br>&lt;%pnum=request.querystring(&quot;PartNumber&quot;)%&gt;<br>&lt;%desc=request.querystring(&quot;Description&quot;)%&gt;<br>&lt;%<br>Set Conn = server.CreateObject(&quot;ADODB.Connection&quot;)<br>Conn.Open &quot;driver=SQL Server;server=smallbserver;uid=sa;pwd=;database=Universal;&quot;<br>Set RS = Conn.Execute(&quot;SELECT Count(*) AS Recs FROM Inventory Where [Part Number] Like N'&quot; & pnum & &quot;%' And [Description] Like N'&quot; & desc & &quot;%'&quot;)<br>Set RS1 = Conn.Execute(&quot;SELECT [Part Number], [Description], [ListPrice] FROM Inventory Where [Part Number] Like N'&quot; & pnum & &quot;%' And [Description] Like N'&quot; & desc & &quot;%'&quot;)<br>%&gt;<br>&lt;form action=&quot;shopcart.asp&quot; method=get&gt;<br><br>&lt;table border=&quot;1&quot; width=&quot;72%&quot;&gt;<br>&nbsp;&lt;tr&gt;<br>&nbsp;&nbsp;&lt;th width=&quot;100%&quot; align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot; valign=&quot;middle&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p align=&quot;left&quot;&gt;&lt;%Response.Write &quot;Records returned &quot; & RS(&quot;Recs&quot;)%&gt;&lt;/th&gt;<br>&nbsp;&nbsp;&lt;/tr&gt;<br>&lt;/table&gt;<br>&lt;table border=&quot;1&quot; width=&quot;72%&quot; bordercolor=&quot;#0066FF&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;10%&quot; align=&quot;left&quot; bordercolor=&quot;#000000&quot; bgcolor=&quot;#000000&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p align=&quot;left&quot;&gt;&lt;font color=&quot;#FFFFFF&quot;&gt;Add to PO&lt;/font&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;20%&quot; align=&quot;left&quot; bordercolor=&quot;#0066FF&quot; bgcolor=&quot;#000000&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p align=&quot;left&quot;&gt;&lt;font color=&quot;#FFFFFF&quot;&gt;Part Number&lt;/font&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;55%&quot; align=&quot;left&quot; bordercolor=&quot;#000000&quot; bgcolor=&quot;#000000&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p align=&quot;left&quot;&gt;&lt;font color=&quot;#FFFFFF&quot;&gt;Description&lt;/font&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;15%&quot; align=&quot;right&quot; bordercolor=&quot;#000000&quot; bgcolor=&quot;#000000&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p align=&quot;left&quot;&gt;&lt;font color=&quot;#FFFFFF&quot;&gt;Price&lt;/font&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&lt;tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;10%&quot; align=&quot;left&quot;&gt;&nbsp;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;20%&quot; align=&quot;left&quot;&gt;&nbsp;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;55%&quot; align=&quot;left&quot;&gt;&nbsp;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;15%&quot; align=&quot;right&quot;&gt;&nbsp;&lt;/td&gt;<br>&nbsp;&nbsp;&lt;/tr&gt;<br>&nbsp;&nbsp;<br>&lt;%<br>If Not RS1.EOF Then<br> Do%&gt;<br> &nbsp;&nbsp;&nbsp;&lt;tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;15%&quot; align=&quot;left&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p align=&quot;center&quot;&gt;&lt;input type=&quot;submit&quot; value=&quot;Add to PO&quot; name=&quot;addtopo&quot;&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;25%&quot; align=&quot;left&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;p align=&quot;center&quot;&gt;&lt;%Response.Write RS1(&quot;Part Number&quot;)%&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;60%&quot; align=&quot;left&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p align=&quot;center&quot;&gt;&lt;%Response.Write RS1(&quot;Description&quot;) %&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;60%&quot; align=&quot;right&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p align=&quot;center&quot;&gt;&lt;%Response.Write RS1(&quot;ListPrice&quot;) %&gt;&lt;/td&gt;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt;<br> &nbsp;&nbsp;&nbsp;&lt;% RS1.Movenext<br> Loop Until RS1.EOF<br>Else<br> <br> Response.Write(&quot;No records or something&quot;) <br>End If<br>%&gt;<br>&lt;/table&gt;<br><br>&lt;p align=&quot;left&quot;&gt;&lt;font size=&quot;1&quot;&gt;Written by: Douglas Poston &lt;a href=&quot;mailto:<A HREF="mailto:dposton@universal1.com">dposton@universal1.com</A>&quot;&gt;<A HREF="mailto:dposton@universal1.com">dposton@universal1.com</A>&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;<br><br>&lt;/body&gt;&lt;/html&gt;<br>---------------------------<br><br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Doug,<br>&nbsp;&nbsp;&nbsp;Change this line:<br><br>&lt;input type=&quot;submit&quot; value=&quot;Add to PO&quot; name=&quot;addtopo&quot;&gt;<br><br>&nbsp;&nbsp;&nbsp;To this:<br><br>&lt;input type=&quot;submit&quot; value=&quot;Add to PO&quot; name=&quot;addtopo_&lt;%=RS1(&quot;partnumber&quot;)%&gt;&quot;&gt;<br><br>This will set the name of the submit button to a concatentation of &quot;addtopo_&quot; and the part number<br><br>Then, in shopcart.asp, iterate through the form collection to get the name of the submit button, and strip off the &quot;addtopo_&quot;<br><br>&lt;%<br>For each key in request.form<br>&nbsp;&nbsp;if left(key,8) = &quot;addtopo_&quot; then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;itemnumber = mid(key,9)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit for<br>&nbsp;&nbsp;end if<br>next<br>%&gt;<br><br>when you have multiple submit buttons in a form, only the one clicked gets sent to the server.<br><br>I wrote this off the of my head without testing, so there may be some typos, but it should point you in the right direction.<br><br><br><br><br> <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
Nick you a genius<br>Thanks man<br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
One slight problem<br>it passes all of this junk<br><A HREF=" TARGET="_new"> is for just 3 parts when I have 40 it passes a whole lot more. also I afraid if the are 200 parts that it will truncate cause there is a limit as to how much you can pass.<br><br>Did I miss something. I made Hidden TEXT box which is being passed to the shopcart I could not get the submit button to pass anything at all.<br><br>Now in the Shop cart .asp I have the For Each... code<br>Can I somehow get only the part number I need and pass just one parameter.<br>This is all new and I am free to do other methods if there is a better way. <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
OK here it is:<br>put this in the calling asp<br>----------------------<br>&lt;%<br>If Not RS1.EOF Then<br> Do%&gt;<br> &nbsp;&nbsp;&nbsp;&lt;tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;15%&quot; align=&quot;left&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p align=&quot;center&quot;&gt;&lt;input type=&quot;submit&quot; value=&lt;%=RS1(&quot;Part Number&quot;)%&gt; name=&quot;addtopo&quot;&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;25%&quot; align=&quot;left&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;p align=&quot;center&quot;&gt;&lt;%Response.Write RS1(&quot;Part Number&quot;)%&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;60%&quot; align=&quot;left&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p align=&quot;center&quot;&gt;&lt;%Response.Write RS1(&quot;Description&quot;) %&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;60%&quot; align=&quot;right&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p align=&quot;center&quot;&gt;&lt;%Response.Write RS1(&quot;ListPrice&quot;) %&gt;&lt;/td&gt;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt;<br> &nbsp;&nbsp;&nbsp;&lt;% RS1.Movenext<br> Loop Until RS1.EOF<br>Else<br> <br> Response.Write(&quot;No records or something&quot;) <br>End If<br>%&gt;<br>----------------------<br>put this in the recieving asp<br>----------------------<br>&lt;%<br>pnum1=request.querystring(&quot;addtopo&quot;)<br>Response.Write &quot; Got here &quot; & pnum1<br>%&gt;<br>-------------<br>It just passses one value and then get it in the &quot;addtopo&quot; variable.<br>Works great!!!!!<br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top