Reply
cbauer50
cbauer50 Member
Member
Posts: 4
Kudos: 0

Drop down menu question

I have created a 'add to cart" button with the drop down menu for the customer to select a color - but I need to make sure that they actually select one - it defaults to the first option.

 

How can I make sure that they actually select a color?

 

thanks.

0 Kudos
cbauer50
cbauer50 Member
Member
Posts: 4
Kudos: 0

Re: Drop down menu question

I am still waiting for some help with this.  Surely someone here has to know the answer.

 

thank

 

cb

0 Kudos
PayPal_Misty
PayPal_Misty Administrator
Administrator
Posts: 1915
Kudos: 83

Re: Drop down menu question

[ Edited ]

Hello cbauer50,

 

I am sorry, I did respond to your post back on December 3rd, but for some reason it did not show my response.

 

Please see my response below to your question.

 

I have created a 'add to cart" button with the drop down menu for the customer to select a color - but I need to make sure that they actually select one - it defaults to the first option.

 

How can I make sure that they actually select a color?

 

The PayPal Add to Cart button with a drop down menu will default to the first option. You can test this button by clicking the drop down menu and selecting an option other than the first one and continue through the check out process (just do not complete the sale). If you are able to add an option (other than the first) to the cart you will know the options are working properly

 

I hope this is helpful.

 

:smileyhappy:Misty

0 Kudos
cbauer50
cbauer50 Member
Member
Posts: 4
Kudos: 0

Re: Drop down menu question

Thanks, but that doesn't help.  So many people forget to actually select something and therefore comes through with the 1st choice.  I would think there has to be a way to not accept the first choice (by putting something like "Select a Color" as the first choice and if they forget to actually select a color - they would be reminded to "select a color."

 

Ebay has that and if one forgets to actually select something, they get a message.

 

Guess I'll have to find a different way.

 

CB

0 Kudos
PayPal_RobG
PayPal_RobG PayPal Employee
PayPal Employee
Posts: 182
Kudos: 11

Re: Drop down menu question

[ Edited ]

Hi CB,

 

I whipped up a quick 'Add to Cart' button with this behaviour.

What follows next may be a bit techie, but you can always just copy / paste my example and simply modify its values to suit your scenario.

 

Step 1:

Add a piece of JavaScript to check the value of 'os0'.

The following will accomplish this:

 

<script type="text/javascript">
function optionCheck(){
var os0 = document.getElementById('os0');
if(os0.value != "") {
return true;
}
else {
alert("Please choose an option!");
return false;
}
}
</script>

 

Step 2:

Add an 'empty' option to the dropdown (with an empty value):

<option value="">Choose a colour</option>

 

Step 3:

Add an onclick handler to the 'submit' button so it fires the JavaScript function when clicked.

onclick='return optionCheck();

 

-------------------------------------------------------------------------------------------

 

Full code (modified parts in bold):

 

<script type="text/javascript">
function optionCheck(){
var os0 = document.getElementById('os0');
if(os0.value != "") {
return true;
}
else {

alert("Please choose an option!");
return false;
}
}
</script>

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="your@email-goes-here.com">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="My item">
<input type="hidden" name="amount" value="9.99">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="products">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="add" value="1">
<table>
<tr><td><input type="hidden" name="on0" value="Colour">Colour</td></tr><tr><td><select
name="os0" id="os0">
<option value="">Choose a colour</option>
<option value="Red">Red</option>
<option value="Blue">Blue </option>
<option value="Orange">Orange </option>
<option value="Yellow">Yellow </option>
</select> </td></tr>
</table>
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_LG.gif"
border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"
onclick='return optionCheck();'>
</form>

 

 

Hope this is useful for you!

 

 

Note: This code is provided as-is; I'll do my best to assist in case any issues arise (they shouldn't), but I can't offer official support on it. 

----
For technical assistance with PayPal merchant product offerings, please file a ticket at https://www.paypal.com/mts/
0 Kudos
cbauer50
cbauer50 Member
Member
Posts: 4
Kudos: 0

Re: Drop down menu question

Thanks so much, RobG - I'll play around with it.

 

CB

0 Kudos