vpnzforum Posted July 9, 2014 Share Posted July 9, 2014 I'm looking for a way to change Return/Enter behavior in a custom field. Example: <tr> <td class="fieldlabel">{$customfield.name}</td> <td class="fieldarea">{$customfield.input} {$customfield.description}</td> </tr> In the configureproduct.tpl file I have a custom field that collects information from the user. Once the information is collected in the custom field if the user hits enter and doesn't click on "Checkout" they are forwarded to: cart.php?configure=true&i=0&billingcycle=monthly&customfield[4]=customfieldData Instead of heading to the checkout (viewcart). Does anyone know how this could be corrected? Thank You, Jason 0 Quote Link to comment Share on other sites More sharing options...
vpnzforum Posted July 9, 2014 Author Share Posted July 9, 2014 I got this to work using the following code directly below the the submit button on configureproduct.tpl. {literal} <script type="text/javascript"> document.getElementById("customfield4").addEventListener("keydown", function(e) { if (!e) { var e = window.event; } e.preventDefault(); // // Enter is pressed if (e.keyCode == 13) { addtocart(); } }, false); </script> {/literal} Hope someone finds this useful. 0 Quote Link to comment Share on other sites More sharing options...
vpnzforum Posted July 9, 2014 Author Share Posted July 9, 2014 Actually that code doesn't work because it prevents characters from being entered in the box. Spoke too soon. Anyone willing to contribute? 0 Quote Link to comment Share on other sites More sharing options...
durangod Posted July 9, 2014 Share Posted July 9, 2014 i wonder if an inline onchange would work better can you share a screen shot so i an see what you mean, a pic helps so much for this old brain lol. 0 Quote Link to comment Share on other sites More sharing options...
vpnzforum Posted July 10, 2014 Author Share Posted July 10, 2014 Ok I figured out I think and this time I actually tested it before posting on configureproduct.tpl in form you can change the default action with the following code. <form id="orderfrm" onsubmit="javascript:addtocart();return false;"> the default action is <form id="orderfrm" onsubmit="javascript:submit();return false;"> but submit(); will forward the user to the cart.php page instead of preceding to checkout. Hope this helps. 0 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.