Administrators Nathan Posted January 8, 2014 Administrators Share Posted January 8, 2014 <form action="/proc" method="post" onsubmit="return check();"> <input type="hidden" name="twelve" value="399"> <div class="quantity"> <input type='button' value='-' class='qtyminus' field='quantity12' /> <input type='text' id='quantity12' value='0' class='qty' name="quantity12"/> <input type='button' value='+' class='qtyplus' field='quantity12' /> </div> </div> <div style="width:300px;float:left;margin-left:30px;"> <input type="hidden" name="twentyfour" value="547"> <div class="quantity"> <input type='button' value='-' class='qtyminus' field='quantity11' /> <input type='text' id='quantity11' value='0' class='qty' name="quantity11"/> <input type='button' value='+' class='qtyplus' field='quantity11' /> </div> </div> <div id="clearfix"></div> <div style="margin-top:175px;"><input type="submit"/></div> </form> Javascript: <script type="text/javascript"> function check() { var elements = document.getElementsByName("quantity11"); var elements1 = document.getElementsByName("quantity12"); for (var i=0; i<elements.length; i++) { var nmbr = parseInt(elements[i].value,10); var nmbr1 = parseInt(elements1[i].value,10); if ((nmbr*2) + nmbr1 > <?php echo $maxqtyorder; ?>){ alert("You've selected more treats than your package allows."); return false; } } return true; } </script> I have a page that includes 2 different options to select. You can select the quantity before you add to your cart. I'm trying to make sure that the quantity the customer selects is not more than a certain total I've already passed to that page. After about an hour of trial and error it worked! HTML: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.