On page script not executing with Salesforce Web-To-Lead code. - javascript

This form works when the form action is "submit". However, upon customizing it to a Salesforce Web-to-Lead, the script that says "The form submission was successful" doesn't appear.
Additionally, the code in here to redirect the site after submission doesn't work. I'm no a PHP/Java expert and I don't really know what's happening enough to understand why it isn't working.
See below. Redacted private info from Salesforce.
<div class="padpage padtop">
<h1>Let Us Call You</h1>
</div>
<!--end padpage-->
<div class="cutContainer moreUpperMargin">
<span class="cutTop"></span>
<span class="cutBottom"></span>
<div class="ui-widget successMessage">
<div class="ui-state-highlight ui-corner-all">
<p><span class="ui-icon ui-icon-info" style=""></span>
<strong>Success!</strong> Your mail has been sent.</p>
</div>
</div>
<h4> Write to us </h4>
<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST" />
<input type=hidden name="oid" value="000000000000000">
<input type=hidden name="retURL" value="http://www.xxxxxxxx.com">
<input type=hidden name="company" value="Mobile Lead">
<!-- A bunch of Fields.... -->
<input type="submit" class="button buttonStrong right" value="Send" name="buttonSubmit" value="submit">
<div class="clearfix"></div>
</form>
</div>
<!--end cut container-->

Can you be more clear about the issue? If you want to use Salesforce standard functionality and presumably not program any custom PHP / Javascript, why don't you create another web page that includes the message, "The form submission was successful", and direct the user to that page through the retURL field upon submission?
Or, if you are using a popular CMS, try one of the plugins. Good ones exist for Wordpress and Drupal.
http://wordpress.org/plugins/salesforce-wordpress-to-lead/
https://drupal.org/project/sfweb2lead_webform
stony

Related

How to link to another page based on a returned value

I have just started using GWTBootstrap. I have set up my login page and now I want to:
If login was unsuccessful stay on page
If value returned from the database is "1" go to htmlpage1.html
If value returned from the database is "2" go to htmlpage2.html
In this way if the wrong login information is entered I do not go to the next page and, if successful login, people with different access levels are presented with different information.
Is there a tutorial that covers this please?
My html code is:
<form class="form-signin">
<h2 class="form-signin-heading">Please sign in</h2>
<input type="text" class="input-block-level" placeholder="Email address">
<input type="password" class="input-block-level" placeholder="Password">
<label class="checkbox">
<input type="checkbox" value="remember-me"> Remember me
</label>
<button id="SignIn" class="btn btn-large btn-primary" type="submit">Sign in</button>
<script type="text/javascript">
document.getElementById("SignIn").onclick = function () {
location.href = "htmlpage1.html";
};
</script>
</form>
</div> <!-- /container -->
You need to create an AJAX request inside on-click method in order to get some response from a POST url, based on it, you will redirect to the correct html.
Anyway, is better to use some framework to do that.

Load a form action in a div on the same page

I have a dealer locator which is powered through software that our IT department manages, and I'm trying to fix up their code a bit and make it more user friendly.
What I'd like to do is allow end users to enter in their zip code, and have the list of dealers in their area show up on the same page, rather than open a new tab/window, or re-load the page.
<div class="locator">
<form method="get" id="dsearchform" action="http://www5.pacelink.com/paceweb/locatorframe.jsp?brand=SWEQ&zip=&&distance=50&numlocations=6&submit=Find+a+Dealer" target="_blank" alt="Pace Search - Sno-Way" onsubmit="return dsearch(this)" class="dealersearch">
<input type="hidden" name="locatorBrand" value="SWEQ" />
<input type="hidden" name="distance" value="100" /><input type="hidden" name="numlocations" value="6" />
<h2>Sno-Way Dealer Locator:</h2>
<h3 class="secondary">Enter your zip code below to find an authorized Sno-Way dealer near you!</h3>
<div class="zip-entry">
<input type="text" name="zip" placeholder="ZipCode" value="ZipCode" class="field" onfocus="if(this.value == 'ZipCode'){this.value='';}" onblur="if(this.value == ''){this.value='ZipCode';}"/>
<input type="submit" name="submit" value="Search" id="button" class="but"/>
</div>
</form>
</div>
I've cobbled this together from another solution posted here, but I don't think it's on the right track at all:
<div id="search">
<form id="try" method="post" target="receiver" action="http://www5.pacelink.com/paceweb/locatorframe.jsp?brand=SWEQ&zip=&&distance=50&numlocations=6&submit=Find+a+Dealer">
Zip: <input id="zip" name="zip" type="text" onfocus="if(this.value == 'ZipCode'){this.value='';}" onblur="if(this.value == ''){this.value='ZipCode';}"/>
<input type="submit"/>
</form>
<div id="receiver">
<?php if (isset($_POST['zip'])){
//display search results here.
}
?>
</div>
</div>
First of
If you want to change the html dynamically you need to go with JavaScript and AJAX. This is , you load stuff asynchronously. The comment states XHR, this is
XmlHttpRequest
Better directly look for the much more convenient JQuery Ajax function.
Jquery is very easy to use.
Example to set html of the container with id retailer
$('#retailer').html(response); // response is the html your php creates
You only need to fetch the html via jquery ajax({... }), where most of the stuff works by default. Just set the url of your webservice and the request body payload) and go. In the callback you do the above and are fine.
Give it a try at
https://learn.jquery.com/ajax/
And inside your html after including the script resource for jquery in the header.
<script>$(document).ready(function(){
// your code goes here
}); </script>
To code your JQuery / JS.
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header" id="content-wrapper">
<h1>
Dashboard <small>${userType} </small>
</h1>
</section>
</div>

How to get around the FormSpree redirect?

I got my website over on the Github Pages Service. I'm trying to implement the FormSpree free contact form but after you submit the form, it redirects you to a different website. Something I'd like to avoid. So I looked it up on the internet and of course others wanted to get rid of it too (I omitted my email in the below picture).
This is the form I got above but it doesn't actually work at all. It worked before I tried to fiddle with it though.
Here is what the form looks like by default from FormSpree:
<form action="//formspree.io/your#email.com"
method="POST">
<input type="text" name="name">
<input type="email" name="_replyto">
<input type="submit" value="Send">
</form>
Here is my version (which worked fine before I tried to get around the redirect)
<div class=modal-body style="background-color: #454545">
<p>Please use the form below to contact us regarding feedback or any questions you may have!
We will never use the information given below to spam you and we will never pass on your
information to a 3rd party.</p>
<p>As we are using <a target="_blank" href="http://formspree.io">FormSpree</a> for this form
please consult their privacy policy for any questions regarding this matter.</p>
<form id="contactform" method="POST">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">Name</span>
<input name="form-name-input" type="text" name="name" class="form-control" required>
</div>
<div class="input-group">
<span class="input-group-addon">Email</span>
<input name="form-email-input" type="email" name="_replyto" class="form-control" required>
</div>
<div class="input-group">
<span class="input-group-addon">Subject</span>
<input name="form-subject-input" type="text" name="subject" class="form-control" required>
</div>
<div class="input-group">
<span class="input-group-addon">Description</span>
<textarea name="form-description-input" name="description" class="form-control" rows="4" cols="60" required></textarea>
</div>
<input type="text" name="_gotcha" style="display:none" />
<input class="btn btn-success" data-dismiss="modal" type="submit" id="form-submit-btn" value="Submit">
<input type="hidden" name="_next" value="http://www.dynamicrealities.net" onclick="FormSentConfirmation()"/>
</div>
<script>
var contactform = document.getElementById('contactform');
contactform.setAttribute('action', '//formspree.io/' + 'dynamicrealities#gmail.com');
</script>
</form>
</div>
<div class="modal-footer" style="background-color: #333333">
<button class="btn btn-danger btn-bg" data-dismiss="modal" type="button" id="form-dismiss-btn" onclick="">Close</button>
</div>
And when I call _next I want it to execute the following alert:
function FormSentConfirmation() {
alert('Thanks for the email, we\'ll be in touch promptly.');
}
When I press the Submit button, all that happens is that the form goes away but I don't receive any emails. I'm probably just doing this wrong as I am fairly new still to HTML/JavaScript.
Update: The feature available only on paid plans.
Use this hidden input field inside the form for redirection after form submission. You can redirect users to a page that you like or you have created by using this code block.
<input type="hidden" name="_next" value="//site.io/thanks.html" />
replace value with a valid thank-you page URL.
Follow this link for a tutorial on how to use Formspree and also a video demo
Follow their AJAX example at the bottom: https://formspree.io/
$("#sendMessage").on("click", function() {
$.ajax({
url: "//formspree.io/dynamicrealities#gmail.com",
method: "POST",
data: {message: "hello!"},
dataType: "json"
});
});
Remember to include jQuery as well for this to work. Remove the:
var contactform = document.getElementById('contactform');
contactform.setAttribute('action', '//formspree.io/' + 'dynamicrealities#gmail.com
and replace it with my code and change the selector. Or use $("form").on("submit"...
Here is my example, which sends you a mail and prompts an alert for the user: http://jsfiddle.net/228d4snb/
Do anything you'd like to do right before that return false;
You can put the form in an iframe so only the iframe gets redirected. What I did was create a separate html doc with just the contact form html (and any associated scripts) and then in my actual contact.html page I put:
<iframe src="contact-form.html" class="container"></iframe>.
Style the iframe to the appropriate size and with no border and it should work swimmingly.

HTML Form Submit does not open new site/doesn't open a site at all

after several hours looking for answer, I still haven't found a solution for my problem. I have a very basic form with some checkbox inputs. But the Submit Button doesn't open the php Script for processing the data.
Here's the form:
<form name="request" action="request.php" method="get">
<h2 id="sum">5.99€</h2>
<h6>Per Month</h6>
<input type="hidden" name="hide">
<!--The Hidden Input is there for testing purposes-->
<input type="submit">
</form>
And here's the full code of the section:
<section id="contact">
<div class="container">
<div class="col-lg-12 text-center">
<h2 class="section-heading">Ordering Form</h2>
<p class="text-muted">Choose some web essentials and add them to your plan
<br><a class="page-scroll">Get to know the essentials</a></p><br>
<form name="request" action="request.php" method="get">
<h2 id="sum">5.99€</h2>
<h6>Per Month</h6>
<input type="hidden" name="hide">
<!--The Hidden Input is there for testing purposes-->
<input type="submit">
</form>
<script type="text/javascript">
//Some JavaScript which doesn't have anything to do with the form
</script>
</div>
</div>
</section>
When i click the submit button its just doesn't do anything. No Error message, no 404, no PHP error.
Hope you can help me!

On Submit Add Entered E-Mail To E-Mail Subscribers List

This question is more than likely a duplicate however I cannot find this question already on StackOverflow.
HTML Snippet
<!-- newsletter widget -->
<div class="widget-container newsletterBox">
<div class="inner">
<h3>Newsletter</h3>
<form method="get" action="#">
<input type="text" value="" name="email" class="inputField" placeholder="Email">
<input type="submit" value="Subscribe" class="btn-arrow">
</form>
</div>
</div>
<!--/ newsletter widget -->
A basic input field with a submit button resides on my html page.
How do I safely add their e-mail to the likes of a .txt file on my server without the person being able to enter code to hack my website?
Is it possible to keep my page .html and not have to use PHP?

Categories