Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   Javascript Forms (https://www.warriorforum.com/programming/136511-javascript-forms.html)

earthgrid 21st October 2009 09:40 AM

Javascript Forms
 
I'm struggling with a problem with makeing my old form work with Javascript. Here is the old form that works with our CGI script:

Code:


  <form method="POST" enctype="application/x-www-form-urlencoded">

.... a series of fields....


  <input type="submit" name="save_meeting_msg" value="  Update  ">

ok this works... however when i try to apply the same syntax to our fancy javascript template (which adds pretty colors to the button etc.) it stops working: here is the code:

Code:



<form id="ContactForm" method="POST" enctype="application/x-www-form-urlencoded">


.... a series of fields....


<a href="#" class="link2" name="save_meeting_msg" onclick="document.getElementById('ContactForm').submit()"><strong><strong>Send</strong></strong></a>

its not passing along the VALUE variable 'save_meeting_msg' to the CGI script so when the form is submitted it doesn't know what to do.

I've looked everywhere and can't seem to find how to use the submit() to pass along the 'name' value in Javascript.

Your help is greatly appreciated.

Robert24 21st October 2009 05:18 PM

Re: Javascript Forms
 
You can't send form data through an a tag.

If you want to send the 'save_meeting_msg' variable/name along with a value then you should create a hidden input field and do it that way.

Hope that makes sense.

cmaclean 22nd October 2009 11:43 AM

Re: Javascript Forms
 
You're better off using a server side form script. I'd suggest using a PHP script like formtoemail. They have a pro version as well.

ereadergold 22nd October 2009 01:48 PM

Re: Javascript Forms
 
Robert is correct, the easiest way of doing this is with a hidden text box holding your 'save_meeting_msg' variable.

Maybe it's complicating things to much but now that you have a "fancy JavaScript form" have you considered submitting the form values via AJAX (i.e. using the XMLHTTP method)? You could pass as many variables as you want as a JSON or XML string. If you use JSON it's really easy to work with the data directly with JavaScript and PHP 5.

Just a thought, best of luck with your project.

Bill


All times are GMT -6. The time now is 02:13 PM.