Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-02-21
2
Medium Priority
?
374 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 750 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

715 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