/    Sign up×
Community /Pin to ProfileBookmark

Getting form data

Hey there,

I’m trying to figure out a very simple problem… I have a ‘subscribe to email’ form on my site’s frontpage. When they hit the submit button I want a small popup window, with no toolbar, menu bar, status bar etc etc to appear, telling the user that their address was submitted successfully. I don’t want to use the “target=”_blank”” option (or whatever).

Presumably I need to use window.open to do this. Fine, but how do I get their email address within the script, so that I can pass it as a URL parameter?! The form accepting the email address is straightforward PHP and is looking for a URL param.

Any suggestions?! Thanks in advance…

Mat

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@oleragFeb 03.2004 — Something like this...?
[code=php]
<html>
<head>
<script type="text/javascript">
var popWin="";

function submitForm(form) {
var val = form.emailField.value;
var windowAtt = "top=10,left=10,width=300,height=300";
if (!popWin || popWin.closed) {
popWin = window.open('', 'popWin', windowAtt);
popWin.document.write('<html>');
popWin.document.write('<body>');
popWin.document.write('<form>');
popWin.document.write('<input type="text" disabled value=' + val + '>');
popWin.document.write('<br>');
popWin.document.write('<input type="button" value="Close" onClick="self.close()">');
popWin.document.write('</form>');
popWin.document.write('</body>');
popWin.document.write('</html>');
popWin.document.close();
}
else {
popWin.focus();
}
form.submit();
}
</script>
</head>
<body>
<b>Email Sample</b>
<form action="#">
Enter Email: <input type="text" name="emailField" size="25" value=""><br>
<input type="button" name="submitBtn" value="Submit" onClick="submitForm(this.form)">
</form>
</body>
</html>
[/code]
Copy linkTweet thisAlerts:
@matstuffauthorFeb 04.2004 — Thanks a lot olerag - I'll try that later (work at the moment, d'oh).

Cheers,

Mat
---

×

Success!

Help @matstuff spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...