Jump to content

AmberA

Members
  • Posts

    2
  • Joined

  • Last visited

AmberA's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. <script> function myFunction() { var x, text; x = document.getElementById("qty").value; if (isNaN(x) || x < 2) { alert('ALERT HERE'); } else { } } </script> <input type="text" size="5" value="1" id="qty" class="form-control" name="{product.qtyboxname}" onblur="{product.recalculateprice}"/> <input type="submit" name="submit{product.productID}" onclick="myFunction();return confirm;" id="submit{product.productID}" value="{labels.cart.addToCartLink}" class="btn btn-default"/> The script works perfectly as I need an alert when a quantity of less than 2 is entered, however, it only shows an 'OK' button on the alert box which takes you directly to the cart page. How can I get the 'return confirm' to work so they have an option to carry onto the cart or to cancel and stay on the same page?
  2. Hi everyone, I'm not the most knowledgeable person when it comes to coding, but I can usually find and achieve what I want through googling a load of stuff, this however has me stumped. We have an online shop which is running fine. With every product it has the enter quantity feature followed by add to cart. One product we sell is sold in singles and the majority of the time customers need 2 or more of it for it to suit its purpose. Even though it is stated on the website that it is sold in singles, customers still buy just one thinking they are getting a pair, which means we are contacting customers daily and having to amend their order. I want to be able to have the cart feature set up so that on this particular product, if they enter a quantity of just one, a box will pop up asking if they're sure they're only wanting just one. Then the option to cancel so they can amend the quantity, or an option to carry on with the purchase and it will then take them straight to the checkout page. But if they enter anything from 2 and over, it will just ignore it and go straight to the checkout page. I've had a look into the Javascript if/else statements, and it seems roughly along the lines of want I'm needing. I just can't figure out the correct way to do it. I can create a dialog box, but it will come up regardless of what quantity you insert, which is not what I'm wanting to achieve. Any help would be absolutely fantastic.
×
×
  • Create New...