I trying to add a two fields to a contact form and append the form data to the submit.

<script type="text/javascript">



$(":submit").click(function () {

$(":submit").click(function () {


I dont know if that helps you, but i added a field for the telephone number in my transaction email: Your telephone number: {{var data.telephone}}

To get this working you need to change the contact form. app/design/frontend/YOURTEMPLATE/default/template/contacts/form.phtml

I added a field there:

<div class="input-box">
                    <input name="telephone" id="telephone" title="<?php echo Mage::helper('contacts')->__('Telephone') ?>" value="" class="input-text" type="text" />
  • Does that use the name or id to pull the data? – Matthew McLennan Nov 17 '14 at 16:02
  • It's the name, not the id. – Reinsch Nov 17 '14 at 16:15

If you want to add extra data to be submitted with a form you should add more form elements (i.e. text input, hidden) within the form which contain the relevant data as their value. A div element does not get submitted with a form. Preferably do this in the relevant template rather than on the fly using JS, but if you have to use JS then use Protoype rather than jQuery as it's the framework of choice for Magento 1.x.

  • prototype is lousy though. Use what you know. – hownowbrowncow Nov 17 '14 at 15:54
  • 100% disagree. What if you don't know how to manipulate resources models, are you just going to use mysqli functions to write to the database? If you want to develop Magento well do it right using best pratices. You should never stop learning as a developer so the fact that Prototype may not be your favourite framework, or perhaps you don't know it as well, is absolutely no excuse for not following best practices. – Jonathan Hussey Nov 17 '14 at 16:04
  • Of course use best practices. Prototype, however, in my opinion is weak compared to jquery. – hownowbrowncow Nov 17 '14 at 16:46
  • I don't support one more than the the other, but Prototype is a perfectly capable framework overall. Some things jQuery does better, but some things Prototype does better. Obviously jQuery has become the framework of choice since Magento was first released, but at the time Prototype was a better fit - hence being picked. Until Magento 2 is released (whenever that may actually end up being) we should continue to use Prototype with Magento 1. – Jonathan Hussey Nov 17 '14 at 16:55
  • fair enough. well put. – hownowbrowncow Nov 17 '14 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.