3 replies
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.
#forms #javascript #submit
  • Profile picture of the author Robert24
    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.
    {{ DiscussionBoard.errors[1303541].message }}
  • Profile picture of the author cmaclean
    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.
    {{ DiscussionBoard.errors[1306156].message }}
  • Profile picture of the author mywebwork
    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
    {{ DiscussionBoard.errors[1306655].message }}

Trending Topics