# paypal and dropdown box selection problem



## psychosurfer (Mar 1, 2005)

Hey all im having a bit of a problem setting up a site to work with paypal shopping cart. i have managed to pass through variables to get information from title price etc which are fixed on the page. The problem i am having is that i also have 2 dropdowns which hold size and colour options here is the problem i cannot work out how to pass the values in the dropdowns through to the paypal shopping cart. please help me out here guys im almost there just need to sort this problem. Thanks


----------



## Sequal7 (Apr 15, 2001)

Heres a drop table form for three sizes and a color option box, the bold part is the form value that will submit to paypal the size and color.


```
<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="T-Shirt">
<input type="hidden" name="amount" value="10.00">
<table>
  <tr>
    <td>
    <b><input type="hidden" name="on0" value="Size"></b>Size</td>
    <td>
    <select name="os0">
     <option value="Select a Size">Select a Size
    <option value="Small">Small
    <option value="Medium">Medium
    <option value="Large">Large
    </select></td>
  </tr>
  <tr>
    <td>
    <input type="hidden" name="on1" value="Color" maxlength="200">Color</td>
    <td>
    <input type="text" name="os1"></td>
  </tr>
</table>
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
```
Search paypal developer site, they may also have different answers there for you to consider.
http://www.paypal.com/cgi-bin/webscr?cmd=p/pdn/intro-outside


----------



## psychosurfer (Mar 1, 2005)

Thanks sequal for your reply but i am still slightly confused i do not see any code in bold so im not sure where values are coming from and also my dropdown box values are also created dynamically from values stored in my database so i am not sure how to pass across the values from the datbase. I think this makes sense. here is my code so you can view it it may make things a little clearer thanks for all help this place has helped me so much. my form is in bold thanks again for any help. I have tried looking on the paypal site but cant seem to find what im looking for.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<%

Dim strItemID
strItemID = trim(request.QueryString("id"))
Dim Recordset1
Dim Recordset1_numRows
Dim SQLQuery
Dim ProductName

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_project_STRING
Recordset1.Source = "SELECT * FROM clothing WHERE Item_ID=" & strItemID
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0

'Variable Assignment from retrieved data
ProductName = Recordset1.Fields.Item("Item_Title").Value 'Name of item
ProductImage = Recordset1.Fields.Item("Item_Image").value 'Product's picture
ProductDescription = Recordset1.Fields.Item("Item_Desc").Value 'Product Desc. text
ProductPrice = Recordset1.Fields.Item("Item_Cost").Value 'Price

Dim Recordset2
Dim Recordset2_numRows

Set Recordset2 = Server.CreateObject("ADODB.Recordset")
Recordset2.ActiveConnection = MM_project_STRING
Recordset2.Source = "SELECT clothing.*, product_options.* FROM clothing LEFT OUTER JOIN product_options ON clothing.Item_ID = product_options.Product_ID WHERE clothing.Item_ID = " & strItemID
Recordset2.CursorType = 1
Recordset2.CursorLocation = 3
Recordset2.LockType = 1
Recordset2.Open()

Recordset2_numRows = 0

%>

Viewing Product - <%= ProductName %>

*






<%= ProductName %>

  







<%= ProductDescription %>







 Cost: £<%= ProductPrice %>   
<% 
If Not (Recordset2.BOF And Recordset2.EOF) Then
Recordset2.Filter = "Option_name = 'Size'"
Response.Write "

Product Size :

"

While Not Recordset2.EOF
Response.Write " Size - "& Recordset2.Fields.Item("Option_Value").Value & ""
Recordset2.movenext
Wend 
Recordset2.Movefirst
Response.Write ""
End If
%>
 

  
<%

If Not (Recordset2.BOF And Recordset2.EOF) Then
Recordset2.Filter = "Option_name = 'Colour'"
Response.Write "

Product Colour :

"

While Not Recordset2.EOF
Response.Write " Colour - "& Recordset2.Fields.Item("Option_Value").Value & ""
Recordset2.movenext
Wend 
Recordset2.Movefirst
Response.Write ""
End If
%>
   

">
">
">

  





 

*

<%
Recordset2.Close()
Set Recordset2 = Nothing
%>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>


----------



## Rockn (Jul 29, 2001)

Add this for your dropdown if they are still set as comma separated values in your table:

<% 
aTemp = Array(rst1("item_sizes"))
%>

<% 'Now, loop through the array and write out it's contents
FOR i = 0 TO UBOUND(aTemp) %>
"><%= Replace(aTemp(i),", ","") %>
<% NEXT %>

Replace what is highlighted in red to match your current recordset for that page. You can use the same thing for colors if they are seeparated by commas.


----------



## psychosurfer (Mar 1, 2005)

they are no longer comma seperated i have had to seperate into a complteely differnt table which i have called product options which has an option id, product id, option name and option value so is something like this 
product_id=1
option id=2
option name=colour
option value=red
the dropdowns are populated by taking the product id finding the option id related to it then loading option values into dropdown boxes one for colour one for size.


----------



## Rockn (Jul 29, 2001)

Then all you need to do is create a repeating region for each option value.


----------



## psychosurfer (Mar 1, 2005)

Sorry Rockn i am a llitle lost could you please point me in the right direction i have been trying to get this to work all week without any joy everytime i edit the values i just get a mesage on the paypal sight saying please enter a value that is not zero. i am totally confused as far as this is concerned i am getting everything right apart from the dropdowns. please help a guy out.


----------



## Rockn (Jul 29, 2001)

You have to set the values for the options as well or you will be passing nothing back to paypal.

"><%= recordset("filedname") %>


----------



## psychosurfer (Mar 1, 2005)

ive got this so far

<*option value=" <%=Recordset2("Option_value")%>"><%=Recordset2("Option_Value")%>*

">
">
">

but i still dont see any results in paypal and i also dont see how this can retrieve the value from the dropdown box. This is driving me nuts man what am i doing wrong?


----------



## Rockn (Jul 29, 2001)

The recordset is only going to return what you tell it to. If you have split out the sizes and colors they also need to be included into your SQL query that creates the recordset. They joins for linked tables also need to be included as part of the query. The way uoi have the option tag set it will not return anything because 1) you don't have opening and closing tags surrounding the option tags and 2) you have not set the option as a repeating region in DW. Learn some basics before you start building a live retail deal.

What is this anyway? "><%=Recordset2("Option_Value")%>

Is Recordset2("Option_value") an actual field in your DB?? You could use recordset one with joins to lined fields and only create one recordset.


----------



## psychosurfer (Mar 1, 2005)

Recordset2("Option_value") is a field in my DB it holds a value ie for colour red green blue or for size small medium large these then relate to a option id which relates to an item id. so when an item is selected the page pases the item id finds all option ids related to that item and then displays the option values in the dropdown box. as far as "quote" Learn some basics before you start building a live retail deal."quote" is ocncerned i think that is a little harsh i am trying and i do not just post questions here as soon as i have a problem i spend alot of time searching the internet and trying to solve problems for myself. I do welcome all the help given on this forum but do not like being insulted. But thankyou for your help also.


----------



## Rockn (Jul 29, 2001)

I didn't mean to be harsh either, but this is pretty basic stuff. If you do it incorrectly you can see you will be in for some serious issues for you and your customers. I am glad to give you any help you need as well. 
The way the database was before with the values separated by commas would have worked just fine placing them into an array and displaying them in a dropdown list and there would have been no need to create a new table.


----------



## psychosurfer (Mar 1, 2005)

This is not for a customer it is a personal site for a business idea that i may be taking on in the future so i decided as i wanted to learn some web design i would try and build it myself this is why my knowledge is minimal and i am having problems i have managed to do everything that i want to as far as this site is concerned and htis is my final problem. I do not know how to approach this part of the system and do not really want to change the design of my database at this point if i can help it. I thought i would be able to just pull the data directly from the dropdown box depending on what was selected this obviously isnt possible the way i have done it so i now need to look at another way to approach this section. Thanks for your help Rockn and id just like to say this place is great im just STRESSED to the max.


----------



## Rockn (Jul 29, 2001)

Are your tables linked via your SQL statements? If they are not linked with joins the data will never be associated with the item you are trying to create the dropdown list for.


----------



## psychosurfer (Mar 1, 2005)

yes they are and they are associated as when the page loads it displays the correct item with the correct options in the dropdown boxes. i just dont understand how to link this to the paypal page its all there i know it is i just cant see how to get it to add to the options on paypal.


----------



## Rockn (Jul 29, 2001)

Send me the code for it. Either that or post it here again.


----------



## psychosurfer (Mar 1, 2005)

Hey rockn heres the code again m8 if you can help me with this it would be great thanks m8.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<%

Dim strItemID
strItemID = trim(request.QueryString("id"))
Dim Recordset1
Dim Recordset1_numRows
Dim SQLQuery
Dim ProductName

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_project_STRING
Recordset1.Source = "SELECT * FROM clothing WHERE Item_ID=" & strItemID
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0

'Variable Assignment from retrieved data
ProductName = Recordset1.Fields.Item("Item_Title").Value 'Name of item
ProductImage = Recordset1.Fields.Item("Item_Image").value 'Product's picture
ProductDescription = Recordset1.Fields.Item("Item_Desc").Value 'Product Desc. text
ProductPrice = Recordset1.Fields.Item("Item_Cost").Value 'Price

Dim Recordset2
Dim Recordset2_numRows

Set Recordset2 = Server.CreateObject("ADODB.Recordset")
Recordset2.ActiveConnection = MM_project_STRING
Recordset2.Source = "SELECT clothing.*, product_options.* FROM clothing LEFT OUTER JOIN product_options ON clothing.Item_ID = product_options.Product_ID WHERE clothing.Item_ID = " & strItemID
Recordset2.CursorType = 1
Recordset2.CursorLocation = 3
Recordset2.LockType = 1
Recordset2.Open()

Recordset2_numRows = 0

%>

Viewing Product - <%= ProductName %>






*<%= ProductName %>*

  







<%= ProductDescription %>







 *Cost:* *£<%= ProductPrice %>*  * 
<% 
If Not (Recordset2.BOF And Recordset2.EOF) Then
Recordset2.Filter = "Option_name = 'Size'"
Response.Write "

Product Size :

"

While Not Recordset2.EOF
Response.Write " Size - "& Recordset2.Fields.Item("Option_Value").Value & ""
Recordset2.movenext
Wend 
Recordset2.Movefirst
Response.Write ""
End If
%>
* 

 * 
<%

If Not (Recordset2.BOF And Recordset2.EOF) Then
Recordset2.Filter = "Option_name = 'Colour'"
Response.Write "

Product Colour :

"

While Not Recordset2.EOF
Response.Write " Colour - "& Recordset2.Fields.Item("Option_Value").Value & ""
Recordset2.movenext
Wend 
Recordset2.Movefirst
Response.Write ""
End If
%>
*   

">
">
">

  





 

<%
Recordset2.Close()
Set Recordset2 = Nothing
%>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>


----------



## psychosurfer (Mar 1, 2005)

If this makes no sense m8 mail me your email address and ill zip up the site and send it over to you Thanks again.


----------



## Rockn (Jul 29, 2001)

This is the section that holds the values passed to paypal

">
">
">

As you can see there are no fields set for color or sizes and paypal requires you to set paramaters for each. Your tag also needs to enclose all form elements including your dropdown fields or they will not be passed to the paypal site. Here is a tutorial on their site to create custom options.

https://www.paypal.com/uk/cgi-bin/webscr?cmd=p/xcl/rec/options-help-outside

You may also need to go into your paypal configuration to define thes custom paramaters.


----------



## psychosurfer (Mar 1, 2005)

aaaah now i see i need to encorporate my dropdown menu into the actual paypal table to allow it to read the values. Now its getting clearer thanks for your help. I think i know where to go from here now cheers everyone for all your help.


----------

