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/
>>52387595var email = $("[name=email]").val();
I'm assuming you're using jQuery.
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 thehttp://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