Solved

HTML "form" multiple conditional actions for user email sign-up using javascript.

Posted on 2014-02-21
2
365 Views
Last Modified: 2014-03-06
I have two forms: form 1 uses external API, form 2 uses server side PHP. Both forms ask for email. Both work fine but require double entry.

Code form 1:
<form action="http://some.link.com" method="post" target="_blank"><input type="text" name="btr_email" placeholder="Email"><input type="hidden" name="btr_url" value="http://other.link.com"><br>
<input type="hidden" name="schedule_type" value="0"><input type="submit" value="Follow"></form>

Open in new window


Code form 2:
<form class="sml_subscribe" method="post"><input class="sml_hiddenfield" name="sml_subscribe" type="hidden" value="1"><p class="sml_name"><label class="sml_namelabel" for="sml_name">Name:</label><input class="sml_nameinput" placeholder="Name..." name="sml_name" type="text" value=""></p><p class="sml_email"><label class="sml_emaillabel" for="sml_email">Email:</label><input class="sml_emailinput" name="sml_email" placeholder="Email Address..." type="text" value=""></p><p class="sml_submit"><input name="submit" class="btn sml_submitbtn" type="submit" value="Submit"></p></form>

Open in new window


What I need:
1. Remove form 2
2. Add check box in form 1, if checked:
                 
                 -make name input field from form 2 visible
                 -pass email address to form 2
 3. Submit to both forms when "Follow" button is pressed.

Thanks!
0
Comment
Question by:Sanction
2 Comments
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 250 total points
ID: 39877379
The easiest way to do this is to use PHP to parse the initial form submission and then send the form data to the desired targets.
0
 
LVL 9

Expert Comment

by:Sar1973
ID: 39879476
1. I'd rather suggest to hide the form rather then removing it from the HTML structure;
2. add an onchange event to the check object that performs:
-document.getElementById("myField").style.display = "inline";
-document.getElementById("myField2").value=document.getElementById("myEmail1");
3. add an onclick event to the button that performs: document.getElementById("myForm2").submit();
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
div to fit another div 8 22
If condition on Html with Asp 11 17
JS does not refresh 6 19
Adding Row and Cell on a table 14 19
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question