Jump to content

Pressing return in custom field


Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated