Shoutbox

Javascript - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Javascript (/showthread.php?tid=67937)

Javascript by Jimbo on 11-01-2006 at 04:22 PM

Can someone code me something that pops up a window when someone comes to my site, which says what is you name. and then once they've netered that, it asks for there email adress. and then everything that has been entered can be stored as text on a webpage(that i specify)


RE: Javascript by Mablung on 11-01-2006 at 05:13 PM

code:
<html>
<head>
<script type="text/javascript">
var name=prompt("Please enter your name","")
var email=prompt("Please enter your email","")
if (name!=null && name!="" && email!=null && email!="")
{
document.write("Name: " + name + "<br>Email: " + email)
}
</script>
</head>
<body>
</body>
</html>

http://w3schools.com/js/tryit.asp?filename=tryjs_prompt
RE: Javascript by Jimbo on 11-01-2006 at 05:17 PM

quote:
Originally posted by Mablung
code:
<html>
<head>
<script type="text/javascript">
var name=prompt("Please enter your name","")
var email=prompt("Please enter your email","")
if (name!=null && name!="" && email!=null && email!="")
{
document.write("Name: " + name + "<br>Email: " + email)
}
</script>
</head>
<body>
</body>
</html>

http://w3schools.com/js/tryit.asp?filename=tryjs_prompt
Looks like it will work, but where can i specify where it saves the names and email addresses, or can they be sent to an email?(mine)

RE: Javascript by Mablung on 11-01-2006 at 05:22 PM

I can't do it with JavaScript (AFAIK), you have to use PHP or ASP.


RE: Javascript by Jimbo on 11-01-2006 at 05:23 PM

quote:
Originally posted by Mablung
code:
<html>
<head>
<script type="text/javascript">
var name=prompt("Please enter your name","")
var email=prompt("Please enter your email","")
if (name!=null && name!="" && email!=null && email!="")
{
document.write("Name: " + name + "<br>Email: " + email)
}
</script>
</head>
<body>
</body>
</html>

http://w3schools.com/js/tryit.asp?filename=tryjs_prompt
so what will this actually do?
RE: Javascript by Mablung on 11-01-2006 at 05:25 PM

It will ask you for your name and email and if you enter them they will be written on the page.


RE: Javascript by Jimbo on 11-01-2006 at 05:27 PM

quote:
Originally posted by Mablung
It will ask you for your name and email and if you enter them they will be written on the page.
Will they be saved on the page, or just viewable by the person that entered them?
RE: Javascript by Mablung on 11-01-2006 at 05:28 PM

Just viewable.


RE: Javascript by Jimbo on 11-01-2006 at 05:34 PM

quote:
Originally posted by Mablung
Just viewable.
Is there any way to save it? or do you have to use PHP or ASP.

RE: Javascript by Felu on 11-01-2006 at 05:38 PM

quote:
Originally posted by Jimbodude
quote:
Originally posted by Mablung
Just viewable.
Is there any way to save it? or do you have to use PHP or ASP.
You'll need PHP or ASP. If you want PHP code i can give it to you.
RE: Javascript by Jimbo on 11-01-2006 at 05:39 PM

quote:
Originally posted by -!Felu!-
quote:
Originally posted by Jimbodude
quote:
Originally posted by Mablung
Just viewable.
Is there any way to save it? or do you have to use PHP or ASP.
You'll need PHP or ASP. If you want PHP code i can give it to you.
Please, hopefully it will work on piczo
RE: Javascript by Jimbo on 11-01-2006 at 05:52 PM

quote:
Originally posted by Puniksem
That script already addresses the script I posted for you previously, achieving the same function. However does not address the point of posting said address to a savable page, as requested. That's a far more complex issue which involves writing to a file on your server as well. thats not just a case of simple java scripting.

code:
<form action="http://www.yourserver.com/cgi-bin/userform.cgi" method="post" onsubmit="return FSubmitValidation(this)">
  <input name="SendMailTo" type="hidden" value="username@youremail.com">
  <input name="redirect" type="hidden" value="http://website_address">


This is the type of cgi-bin prompting using the SendMailTo command, I used for sending forms to a cgi server which would then send the form content to the specified email address.

If I can get the time I will write you up a script for said task, seeing that's the nearest I can get to your request.
Thanks but most browsers now show a security allert when trying to automatically send an email.

RE: Javascript by Jimbo on 11-01-2006 at 06:11 PM

quote:
Originally posted by Puniksem
That script doesn't send an email directly, instead it sends the form content forward to the cgi-bin which does the emailing. so you should get no popup alert.
ok, whats the redirect bit about?


whats this bit about?
code:
<input name="redirect" type="hidden" value="http://website_address">


sorry for double posting
RE: Javascript by hmaster on 11-02-2006 at 04:37 PM

Thats usually used when you want to direct your viewers to another page when they've submitted the information.


RE: Javascript by Jimbo on 11-02-2006 at 04:46 PM

quote:
Originally posted by hmaster
Thats usually used when you want to direct your viewers to another page when they've submitted the information.
if i don't wanna redirect them, can i just delete it from the code

RE: Javascript by vaccination on 11-02-2006 at 04:56 PM

JimboDude, just mess around with the code, keep a copy of it in a *.txt file or something and then remove the redirect bit and see what happens, or just make it redirect to your hompage again. (Although would that trigger the pop-up again?)

Anyway you allways have that copy of it saved if anything goes wrong.

(oh and keep a fresh copy of the code you had before you added anything to it.)

that way you don't have to worry about messing anything up. One you've had a go you can come back and ask if things went wrong. =)