Forum Moderators: open

Message Too Old, No Replies

Confirmation Window (help)!

         

andynick

8:18 am on Aug 19, 2010 (gmt 0)

10+ Year Member



My first ever attempt at JavaScript, so please be gentle with me . . .

I have "Buy Now" buttons on my page and I want to alert certain buyers that the product may not be suitable for their location.

This is what I've come up with so far but if the buyer clicks "YES" I want the "Buy Now" button to activate (not necessarily with a window alert).

If they click "NO" I want to cancel the action and return a "CANCELLED" message of some sort.

<html>
<head>
<script type="text/javascript">
function message()
{
var x=window.confirm("Make a decision - YES or No")

if (x)
window.alert("Yes goes ahead with button action")
else
window.alert("No cancells the button action and displays a cancellation message.")
}
</script>
</head>

<body>
<form>
<input type="button" value="Click me!" onclick="message()" />
</form>
</body>
</html>

Can anyone help me please?

Fotiman

1:16 pm on Aug 19, 2010 (gmt 0)

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



When you say you want the "Buy Now" button to *activate*, what exactly do you mean? Is this an actual form button (using <input type="button"...)? Is that button already included in the markup?

andynick

1:44 pm on Aug 19, 2010 (gmt 0)

10+ Year Member



Its a PayPal "Buy it Now" type button.

When the buyer clicks the button, I want to warn them that the product may not be suitable for use in their country.

If they click "OK" I'd like the transaction to go ahead - but if they click "CANCEL" I'd like the PayPal transaction to be scrapped (in other words, not go to the PayPal page) if that's possible.

Not sure what you mean by 'already in the markup' - sorry.