[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

hi /g/ how do I store form data as a javascript variable? fo

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 16
Thread images: 3

File: gmail.png (3KB, 204x204px) Image search: [Google]
gmail.png
3KB, 204x204px
hi /g/
how do I store form data as a javascript variable? for example how would I store the user's email adress as
var email = [email protected]

<form action="thankyou.html" method="post" id="emailcap">
E-mail: <input type="text" name="email">
<input type="submit" value="send"></form>


thanks
>>
quick note: I can't use php on that exact page therefore it must be javascript
>>
>>52387595
https://api.jquery.com/serialize/
>>
>>52387595
var email = $("[name=email]").val();

I'm assuming you're using jQuery.
>>
File: video.jpg (29KB, 340x233px) Image search: [Google]
video.jpg
29KB, 340x233px
This script for some reason takes me to www.name.com/?name=INPUT&email=INPUT2
instead of my hyperphp url, I don't think it's a redirect from hyper php since if I enter the code with the data manually it works correctly

what do?


<html><head>
<script type="text/javascript">
function goToPage() {
var name = document.getElementById('name').value;
var email = document.getElementById('email').value;
var thepage = "MYTOPSECRETURL?name=" + name + "&email="+ email;
window.location = thepage;
}
</script>
</head><body>
name<input type="text" id="name" />
email <input type="text" id="email" />
<input type="submit" value="submit" onclick="goToPage();" />
</script>
</body>

</html>
>>
>>52388697
Works fine here. Change the URL for a random third party one to verify it's not your script.

<html><head>
<script type="text/javascript">
function goToPage() {
var name = document.getElementById('name').value;
var email = document.getElementById('email').value;
var thepage = "http://bbc.co.uk?name=" + name + "&email="+ email;
window.location = thepage;
}
</script>
</head><body>
name<input type="text" id="name" />
email <input type="text" id="email" />
<input type="submit" value="submit" onclick="goToPage();" />
</script>
</body>

</html>
>>
>>52388944
I tried it with facebook.com?blahblah
still took me to name.com/?blahblah instead
>>
infact, here:

http://fastimpression.hyperphp.com/form.html
>>
>>52389024
>>52389053
You forgot the
http://
in `thepage`.

Without it, your browser will try to load a relative URL.
>>
>>52389053
>>52388944
update: it only redirects to www.name.com on mozilla, it is fine on internet explorer?
>>
>>52389170
just fixed that myself, silly error when I was hiding my url
try it now.
>>
>>52389170
please let me know what browser you use
>>
>>52389201
Seems to work, I get "Thankyou".
>>
>>52389242
that means it works, here's what it sends me to on firefox:
https://www.name.com/?name=testname&[email protected]&utm_expid=3399857-40.ep5u_QPVQ3KtPVAJKFYWJA.0&utm_referrer=http%3A%2F%2Ffastimpression.hyperphp.com%2Fform.html

I'm checking everywhere for malware or shitty addons that I may have accidentally downloaded but I don't see anything that might cause it, even reinstalled firefox
>>
>>52389232
>>52389302
Tried on Chrome, Safari, and Firefox. Can't reproduce. Whatever you've got going on there, it's on your end.
>>
>>52389407
thanks for testing it bro, at least I know it's my end
it seems to do it when I'm logged out too
Thread posts: 16
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.