Solved

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

Posted on 2014-02-21
2
372 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

635 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