Passing form data from one page to another html mobile page - javascript

I'm new to mobile development and I am trying to pass information from a form and I want to display it on another page. I have tried passing the info using cookies but with no success..
Here is my code for the form:
function submit_jobs_post(){
$.cookie('job_title', $('#job_title').val());
$.cookie('job_des', $('#job_des').val());
$.cookie('company_name', $('#company_name').val());
$.cookie('company_address', $('#company_address').val());
$.cookie('company_phone', $('#company_phone').val());
$.cookie('company_email', $('#company_email').val());
}
<form method="post" action="jobs_page.html" id="post_ads">
<label for="job_title">Job Title:</label>
<input type="text" name="job_title" id="job_title">
<label for="job_des">Job Description:</label>
<textarea name="job_des" id="job_des"></textarea>
<label for="company_name">Company Name:</label>
<input type="text" name="company_name" id="company_name">
<label for="company_address">Address:</label>
<input type="text" name="company_address" id="company_address">
<label for="company_phone">Phone:</label>
<input type="text" name="company_phone" id="company_phone">
<label for="company_email">Email:</label>
<input type="email" name="company_email" id="company_email" placeholder="Your email..">
<input type="submit" data-inline="true" value="Post Job" onClick='submit_jobs_post()'>
</form>
And here is my code for the page to receive the information. When I submit the form the data does not appear on this page.
window.onload = function()
{
$('#job_title_got').val($.cookie('job_title'));
$('#job_des_got').val($.cookie('job_des'));
$('#company_name_got').val($.cookie('company_name'));
$('#company_address_got').val($.cookie('company_address'));
$('#company_phone_got').val($.cookie('company_phone'));
$('#company_email_got').val($.cookie('company_email'));
};
<input type="text" name="job_title_got" id="job_title_got">
<textarea name="job_des_got" id="job_des_got"></textarea>
<input type="text" name="company_name_got" id="company_name_got">
<input type="text" name="company_address_got" id="company_address_got">
<input type="text" name="company_phone_got" id="company_phone_got">
<input type="email" name="company_email_got" id="company_email_got" >
Any help would be great, thanks in advance...

Related

On submit and o'clock not working together

I have read previous posts on this and have tried to apply the onsubmit on my form element in HTML but still doesn't seem to work. I have it as follows:
<form class="button" id="arrow" onsubmit='return hotelList()'>
<input type='submit' value='Submit'/>
</form>
and js:
const hotelList = () => window.location.href = './ochome.html';
Any suggestions? Thank you
Full code:
New Question: my required field does not seem to be working, and the sends me to the other page regardless....
enter code here
<form action="/user-details.html" class='login'>
<!-- is this GET or POST?? -->
<label for="username" >Username</label><br>
<input class="whitebox" type="text" id='username' required/>
<label for="pass" id='pass'>Password</label><br>
<input class="whitebox" type='password' id='passBox' required/>
<input type="submit" id='arrow' value="> Submit">
</form>
the form contains all the input you want to submit and the action is like: action="/file.js" and it has to be a file which handles the data
the code:
<form action="/user-details.html">
<label for="fname">First name:</label><br>
<input class="whitebox" type="text" id='username' required/>
<label for="lname">Last name:</label><br>
<input class="whitebox" type='password' id='passBox' required/>
<input type="submit" value="Submit"/>
</form>

How To Submit Two Forms With One Button?

Please I have these two forms below. The first is the form that submit it's data to my database after my customer buys my product and were redirected to the registration page where the form is, while the second form is the form that submit it's data to my getresponse autoresponder campaign.
Now only the first form is what I wanted to be visible, I don't want the second form to be visible and I want to use one button to submit the two forms at one time, please how will I do that?
Thanks!
<!--====================================================================
Form that submit to my database and register my customers after purchase
======================================================================-->
<form class="form-horizontal templatemo-contact-form-1" role="form" action="sold.php" method="post">
<input type="text" class="form-control" id="name" placeholder="Enter Your First Name Here..." name="fname" required><br>
<input type="text" name="lname" class="form-control" id="name" placeholder="Enter Your Last Name Here..." required><br>
<input type="email" name="email" class="form-control" id="email" placeholder="Enter Your Email Here..." required><br>
<input type="text" name="phone" class="form-control" id="name" placeholder="Enter Your Phone Number Here..." required><br>
<input type="password" name="pword" class="form-control" id="website" placeholder="Enter Your Password Here..." required><br>
<input type="password" name="cpword" class="form-control" id="subject" placeholder="Re-enter Your Password Here..." required><br>
<input type="text" name="addrss" class="form-control" id="name" placeholder="Enter Your Address Here..." required><br>
<input type="submit" value="Register" class="btn btn-success pull-right">
</form>
<!--======================================================
Form that submit to my getresponse autoresponder campaign
========================================================-->
<form action="https://app.getresponse.com/add_subscriber.html" accept-charset="utf-8" method="post">
<input type="text" name="name" value="Enter your name here..." type=text style="width: 100%">
<input type="text" name="email" value="Enter your email here..." type=text style="width: 100%">
<!-- Get the token at: https://app.getresponse.com/campaign_list.html -->
<input type="hidden" name="campaign_token" value="ljqOk" />
<!-- Thank you page (optional) -->
<input type="hidden" name="thankyou_url" value="https://www.moneycreativesecret.com/spages/smf-sp1/"/>
<!-- Add subscriber to the follow-up sequence with a specified day (optional) -->
<input type="hidden" name="start_day" value="0" />
<!-- Forward form data to your page (optional) -->
<input type="hidden" name="forward_data" value="post" />
<input type="submit" value="100% Free Access" class="btn btn-success pull-right">
</form>

How to submit a form without putting an onload event in the body tag

I have several forms synced to Salesforce currently running on a WordPress website using the Avada theme, but the client wants a new field added which will require adding an onload event in the body tag. I thought the easiest way to do this would be to go through the dashboard>Theme Options>Advanced>Code Fields but I don't see an option to add an event to the body tag. What's the best way to do this without editing the core template files (the forms are only on a few pages)?
Snippet of current code:
<form action="https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST"><input type=hidden name="oid" value="00DU0000000H99p">
<input type=hidden name="retURL" value="https://www.sablesys.com/thank-you/">
<input type="hidden" name="member_status" value="Sent"/>
<!-- Campaign id for Quote Campaign -->
<input type="hidden" name="Campaign_ID" value="7010B000001Eiz3QAC" />
<input type="hidden" id="lead_source" name="lead_source" value="Website">
<label for="first_name">First Name</label><input id="first_name" maxlength="40" name="first_name" size="20" type="text" required/><br>
<label for="last_name">Last Name</label><input id="last_name" maxlength="80" name="last_name" size="20" type="text" required/><br>
<label for="company">Company</label><input id="company" maxlength="40" name="company" size="20" type="text" required/><br>
<label for="email">Email</label><input id="email" maxlength="80" name="email" size="20" type="text" required/><br>
<label for="city">City</label><input id="city" maxlength="40" name="city" size="20" type="text" required/><br>
Notes:<br><textarea id="00NU0000003mN8A" name="00NU0000003mN8A" rows="25" type="text" wrap="soft" style="width: 100%"></textarea><br>
<input type="submit" name="submit">
</form>
New code the client requested be added:
A new field for the form:
<input type="hidden" id="URL" name="URL" value="" >
A new onload event:
<body onload="document.getElementById('URL').value = document.location.href">
Is there a way to do a window.onload inside a script instead? I admit I don't know javascript well. Please be descriptive in your replies. Thanks.
This line of code IS javascript.
document.getElementById('URL').value = document.location.href;
You just need a way to get it executed.
If any other javascript code is executing on your page, make it part of that.
You could add an "onsubmit" event to the form, like so:
<form onsubmit="FillInURL()">
<input id="URL" type=hidden>
</form>
function FillInURL() {document.getElementById('URL').value = document.location.href;}

Javascript alert not working on website

I have tried several different things in javascript but nothing seems to work on my site. I'm trying to have an alert pop up when submitting a form. This is what I have
<form>
Name:<br>
<input type="text" name="name" required><br>
Email:<br>
<input type="email" name="email" required><br>
Phone (Format: 999-999-9999):<br>
<input type="tel" name="phone" required pattern="\d{3}[\-]\d{3}[\-]\d{4}"><br>
Nature of comment:<br>
<input type="checkbox" name="comment" value="Question"> Question
<input type="checkbox" name="comment" value="Business Inquiry"> Business Inquiry
<input type="checkbox" name="comment" value="Comment"> Comment
<input type="checkbox" name="comment" value="Other"> Other <br>
Comment:<br>
<textarea></textarea><br>
<input type="submit" value="Submit">
<form onsubmit="return confirm('Do you really want to submit the form?');">
</form>
This is the website: http://webpages.uncc.edu/~kjardine/MC_Portfolio/contact.html
You were almost there, the key is the code you have already has a <form> tag which starts on line 1, so you should add your onsubmit="" attribute into that one. Here is the revised code that should do the trick:
<form onsubmit="return confirm('Do you really want to submit the form?');">
Name:<br>
<input type="text" name="name" required><br>
Email:<br>
<input type="email" name="email" required><br>
Phone (Format: 999-999-9999):<br>
<input type="tel" name="phone" required pattern="\d{3}[\-]\d{3}[\-]\d{4}"><br>
Nature of comment:<br>
<input type="checkbox" name="comment" value="Question"> Question
<input type="checkbox" name="comment" value="Business Inquiry"> Business Inquiry
<input type="checkbox" name="comment" value="Comment"> Comment
<input type="checkbox" name="comment" value="Other"> Other <br>
Comment:<br>
<textarea></textarea><br>
<input type="submit" value="Submit">
</form>
The onsubmit should go in the form element at the top, like the commenter said. and the form element its in currently should be deleted.
That said, you could also have checked a "dont show any more popups" option once for that website, and now popups will be disabled until you enable the popups again, by clearing your chrome cache for instance.
<form onsubmit="return confirm('u sure?');">
<input>...
</form>
I also advise against using onsubmit as an HTML parameter, and instead writing a js handler in an actual <script></script block to do the confirm.
window.onload = function () {
document.getElementById("myForm").onsubmit = function onSubmit(form) {
return confirm('u sure?');
}
}
Remember to add id="myForm" to your form element in this case.

Radio button selection for paypal form issue

need your help
So i have a paypal form which also has two radio buttons. One with a shipping value, and one without. Here is the link to the actual form
http://www.topchoicedata.com/test.php
What i want to happen is that if a person selected the first radio box("$19.99 Shipping – DATABASE SENT ON CD ROM"), then 19.99 would automatically be added to the "hdwppamount" amount which is set at $175, so when the person press's "pay now", it will make a grand total of $194.99 on the paypal page.
And if the person selected the second option instead("FREE SHIPPING – DATABASE SENT VIA EMAIL") instead, then of course no value is added to the "hdwppamount" amount and $175 would be the total for the paypal page.
Now the code does work if the person chooses on or the other options, and then does not alternate between the radio buttons deciding which one they choose. So its kind of buggy because if i choose the first option, then decided the second option, and so on and so forth alternating, i either get an error page or if i did choose the free option, the 19.99 still gets added.
I need so that if the first option is chosen, then the 19.99 gets added, and if the second option chosen, then nothing is added.
Any help would be appreciated.
<!--------------------HTML Form---------------------_
<form action="PPPaymentForm/PPPaymentForm.php" method="post" name="topchoiceform" id="topchoiceform">
<input placeholder="Company Name" type="text" name="companyname" required>
<input placeholder="First Name" type="text" name="first_name" required>
<input placeholder="Last Name" type="text" name="last_name" required>
<input placeholder="Email" type="email" name="email" id="email" required>
<input placeholder="Address" type="text" name="address1" required>
<input name="shipping" class="shipping" type="radio" id="shipping" checked/>
<label class="shippingcheck">$19.99 Shipping – DATABASE SENT ON CD ROM </label>
<br>
<input name="shipping" class="shipping" type="radio" id="noshipping"/>
<label class="shippingcheck">FREE SHIPPING – DATABASE SENT VIA EMAIL</label>
<br>
<button name="submit" type="submit" id="submit">Pay Now</button>
<!-------------Paypal Part------------->
<input type="hidden" name="hdwtablename" id="hdwtablename" value="1">
<input type="hidden" name="hdwppproductname" id="hdwppproductname" value="Basic Plan 175">
<input type="hidden" name="hdwppamount" id="hdwppamount" value="175">
<input type="hidden" name="hdwppcurrency" id="hdwppcurrency" value="USD">
<input type="hidden" name="hdwpplanguage" id="hdwpplanguage" value="en_US">
<input type="hidden" name="hdwok" id="hdwok" value="http://www.topchoicedata.com/paymentmadethanks.php">
<input type="hidden" name="hdwemail" id="hdwemail" value="mauriceflopez+gmail.com">
<input type="hidden" name="hdwnook" id="hdwnook" value="http://">
<input type="hidden" name="hdwactivation_email" id="hdwactivation_email" value="email">
<input type="hidden" name="plan" id="plan" value="$175">
<input type="hidden" name="shippingchoosen" id="shippingchoosen" value="">
<input type="hidden" name="shippingnumber" id="shippingnumber" value="">
</form>
PHP
<script>
$('#shipping').change(function(){
var hdwppamount = Number($("#hdwppamount").val())
var shippingcost = 19.99;
if (this.checked) {
$("#hdwppamount").val(hdwppamount+shippingcost)
} else {
$("#hdwppamount").val(hdwppamount-shippingcost)
}
})
</script>
With radio you may have only one of them checked at a time. This means you have to test which one is checked in a specified moment (i.e.: change event).
I changed the input field hdwppamount from hidden to text in the snippet to make clear the behaviour.
$(function () {
$('#shipping, #noshipping').on('change', function(){
var hdwppamount = Number($("#hdwppamount").val());
var shippingcost = 19.99;
if (this.id == 'noshipping') { // shipping unchecked
$("#hdwppamount").val(hdwppamount-shippingcost);
} else { // shipping checked
$("#hdwppamount").val(hdwppamount+shippingcost);
}
});
// initialize the field with the correct value
$("#hdwppamount").val('194.99');
});
<script src="https://code.jquery.com/jquery-1.12.1.min.js"></script>
<form action="PPPaymentForm/PPPaymentForm.php" method="post" name="topchoiceform" id="topchoiceform">
<input placeholder="Company Name" type="text" name="companyname" required>
<input placeholder="First Name" type="text" name="first_name" required>
<input placeholder="Last Name" type="text" name="last_name" required>
<input placeholder="Email" type="email" name="email" id="email" required>
<input placeholder="Address" type="text" name="address1" required>
<input name="shipping" class="shipping" type="radio" id="shipping" checked/>
<label class="shippingcheck">$19.99 Shipping – DATABASE SENT ON CD ROM </label>
<br>
<input name="shipping" class="shipping" type="radio" id="noshipping" />
<label class="shippingcheck">FREE SHIPPING – DATABASE SENT VIA EMAIL</label>
<br>
<button name="submit" type="submit" id="submit">Pay Now</button>
<!-------------Paypal Part------------->
<input type="hidden" name="hdwtablename" id="hdwtablename" value="1">
<input type="hidden" name="hdwppproductname" id="hdwppproductname" value="Basic Plan 175">
<input type="text" name="hdwppamount" id="hdwppamount" value="175">
<input type="hidden" name="hdwppcurrency" id="hdwppcurrency" value="USD">
<input type="hidden" name="hdwpplanguage" id="hdwpplanguage" value="en_US">
<input type="hidden" name="hdwok" id="hdwok" value="http://www.topchoicedata.com/paymentmadethanks.php">
<input type="hidden" name="hdwemail" id="hdwemail" value="mauriceflopez+gmail.com">
<input type="hidden" name="hdwnook" id="hdwnook" value="http://">
<input type="hidden" name="hdwactivation_email" id="hdwactivation_email" value="email">
<input type="hidden" name="plan" id="plan" value="$175">
<input type="hidden" name="shippingchoosen" id="shippingchoosen" value="">
<input type="hidden" name="shippingnumber" id="shippingnumber" value="">
</form>

Categories

Resources