javascript - Redirecting customers based on the product they select -
i've got shopping cart , depending on product.id
, need send potential client corresponding url (the form action url).
here's of html:
<div id="product-pricing"> <form name="product_form" action="/cart/add"> <div class="single-item"> <p class="price">$9.99</p> <input type="hidden" name="id" value="00001"> <input class="btn" type="submit" name="add" id="add-to-cart" value="add cart"> </div> </form> </div>
can somehow read value
field using javascript or without jquery (which include in header section) , then, within code, have outcome defined like:
if id="00001" form action="http://domain.com/page1.php" if id="00002" form action="http://domain.com/page2.php" if id="00003" form action="http://domain.com/page3.php" if id="00004" form action="http://domain.com/page4.php" if id="00005" form action="http://domain.com/page5.php"
so, if user orders id="00002" , clicks "add cart" button, go http://domain.com/page2.php
. or, if user picks product id "00004" , clicks "add cart" button, go straight http://domain.com/page4.php
.
in short, need redirect potential client different page depending on product order. how can accomplish this?
you can this:
<script> var yourid = $("input[name='id']").val(); if (yourid = "someid") $("form[name='product_form']").attr("action","your_link"); </script>
javascript jquery html forms
No comments:
Post a Comment