PDA

Click to See Complete Forum and Search --> : I Guarantee Nobody Here Can Answer This Question!


Zaphod64831
Feb 18th, 2001, 03:02 PM
I know that nobody here will answer this question, because this is the third time I've tried. But, I like to do this anyway because its such a simple question that you'd expect ANYBODY that had ANY experience at all with Javascript could answer this question without even thinking about it. It's been my experience that it's far more difficult a question than anybody had ever expected or believed possible.

Now, without further ado, the most difficult question in the Universe:

I've got a simple form, nothing fancy, it just sends the data in the fields to an e-mail address via the mailto: in the action attribute. There's just one problem, when the user clicks on the submit button it seems as if nothing happens, so they keep clicking and clicking and clicking unknowingly submitting five or more of the same form. What I need is a javascript that would redirect the user's browser to a specified URL when they click on the submit button.

Sounds simple, doesn't it? Well, think again, because a simple little OnSubmit event handler in the form tag never worked, maybe I wasn't doing it right but I didn't exactly have much help. Same goes for an OnClick in the Submit button.

The race is on, who can answer the most difficult known question in the Universe?

Zaf Khan
Feb 18th, 2001, 03:29 PM
Post your code.....

DocZaf
{;->

Zaphod64831
Feb 18th, 2001, 03:36 PM
There's a problem there, my comp crashed and I couldn't back that up.
Sorry...

Danial
Feb 18th, 2001, 04:13 PM
Hi,

Instead of using JavaScript why not use ASP, i use asp to submit my forms. You can sign up free asp accounts with www.domaindlx.com. If you are not familiar with asp then i can set it up for u.

sail3005
Feb 18th, 2001, 04:53 PM
i don't know, as i recall, i helped you with the old post, and got it to work, at least in IE, maybe not ns.

or you could just have an alert pop up when you submit the form.

Psyrus
Feb 18th, 2001, 04:58 PM
You could try to use a regular "button" and not a "submit" one and call a function to take care of it like this:


<script>

function sendData(){

sendMe.submit();
window.location = '/thanks.html';

}

</script>

<form ID = "sendMe" METHOD = "post" ACTION = "youraction">

...other form stuff

< input TYPE = "button" VALUE = "Submit" ONCLICK = "sendData();">

</form>

By calling submit() this will submit the form and location can then be used to change the current page, just supply the desired URL as a string to it. I haven't tested this out but it should work.

Danial
Feb 18th, 2001, 06:40 PM
Try this code



<html>
<head>
<title>Untitled Document</title>

<script>
function submitIt()
{
var temp;
temp=window.open("","noname");
temp.document.write('<h1>Thanks for your email !!</h1>');

}
</script>

</head>

<body bgcolor="#FFFFFF">
<form method="post" action="mailto:you@yourmail.com" name="form1">
<p> Name :
<input type="text" name="txtName">
</p>
<p> Email :
<input type="text" name="txtEmail">
</p>
<p>
<input type="submit" name="Suubmit" value="Suubmit" onclick="submitIt()" >
<input type="reset" name="Submit2" value="Reset">
</p>
</form>
</body>
</html>


Or if you can open a html file instead of using document.write. Just use Window.open("filename.htm");

Zaphod64831
Feb 18th, 2001, 07:08 PM
Thank you all, and I'm sorry sail but I do need it to be as completely compatible as possible. Glad to finally get an answer to this question =)

rjlohan
Oct 10th, 2001, 06:00 PM
42

Zaphod64831
Oct 10th, 2001, 09:06 PM
Did you just search for my name and decide to reply to all my posts? ;)

rjlohan
Oct 10th, 2001, 09:27 PM
:)

I've had that with people, but no, I don't really even notice...

:p

CiberTHuG
Oct 11th, 2001, 10:23 AM
Okay, this is an untested solution, and I'm not going to rebuild the whole page. You should've atleast done that when someone asked for the code. You will have to do it anyway.


<a href="JavaScript:GoGoGo();">Send Mail</a>

<script type="text/javascript">
function GoGoGo() {
document.myMailForm.submit();
document.myRedirectForum.submit();
}
</script>


Like I said, I don't know if this will work, but you hopefully see where I'm going with it and you can test it out.

CiberTHuG
Oct 11th, 2001, 10:25 AM
Originally posted by Danial
Instead of using JavaScript why not use ASP, i use asp to submit my forms.

Uhm, no, you don't. ASP is a server side scripting technology. It may dynamicaly create forms, and it may dynamicaly create pages in response to what has been submitted in forms, but it it doesn't actually submit a form.

progressive
Oct 12th, 2001, 04:53 AM
Why would you want to submit a form using mailto??

You have to decipher it when the mail arrives!


select=hello&Submit=Submit


What a nasty way to do things even a free perl/vbscript provider would be better than this method surely!

Anyone else agree?

Danial
Oct 12th, 2001, 03:38 PM
Originally posted by CiberTHuG


Uhm, no, you don't. ASP is a server side scripting technology. It may dynamicaly create forms, and it may dynamicaly create pages in response to what has been submitted in forms, but it it doesn't actually submit a form.

Yes i know. ASP is a server side technology and know the difference between server side and client side technology, and know what they are capable of !!

I actually meant you could submit the result of the forms to an asp file and process it and use asp to send the email. AS if you use mailto: then the user will have to use their defualt mail client to send the mail and some user dont have it set up in their system, and its pretty annoying some times. So thats why i suggested ASP !!

Hey English has never been my first language :D

Zaf Khan
Oct 12th, 2001, 06:23 PM
Hear Hear


I actually meant you could submit the result of the forms to an asp file and process it and use asp to send the email. AS if you use mailto: then the user will have to use their defualt mail client to send the mail and some user dont have it set up in their system, and its pretty annoying some times. So thats why i suggested ASP !!



DocZaf
{;->

da_silvy
Oct 15th, 2001, 06:37 AM
Originally posted by progressive
Why would you want to submit a form using mailto??

You have to decipher it when the mail arrives!


select=hello&Submit=Submit


What a nasty way to do things even a free perl/vbscript provider would be better than this method surely!

Anyone else agree?

PHP would do this very easily, so would perl

progressive
Oct 15th, 2001, 06:52 AM
PHP would do this very easily, so would perl

What do you mean da_silvy?

If you meen once you have recieved the mail that was sent to you using the mailto command you could then decipher it using Perl or PHP.

Then i have this question why the hell wouldn't you use Perl or PHP to send it in the first place ??

:eek:

If you don't meen that then please ellaborate further!

CiberTHuG
Oct 15th, 2001, 10:21 AM
Originally posted by Danial
I actually meant you could submit the result of the forms to an asp file and process it and use asp to send the email. AS if you use mailto: then the user will have to use their defualt mail client to send the mail and some user dont have it set up in their system, and its pretty annoying some times. So thats why i suggested ASP !!


I agree with this tactic completely. It keeps your email address of off the page, and avoids problems for user agents that do not have mail clients or POP servers.

I wouldn't submit a mailto form and then a redirect. I would submit to an ASP that passes the address and info to a shell script and then redirects to a second ASP that generates the next page.

But since this is a client scripting forum and he was asking in a for a JavaScript solution....

da_silvy
Oct 15th, 2001, 04:30 PM
Originally posted by progressive


What do you mean da_silvy?

If you meen once you have recieved the mail that was sent to you using the mailto command you could then decipher it using Perl or PHP.

Then i have this question why the hell wouldn't you use Perl or PHP to send it in the first place ??

:eek:

If you don't meen that then please ellaborate further!


Sorry progressive, i meant to use Perl or PHP to send it all together :)

Danial
Oct 16th, 2001, 05:05 PM
Originally posted by CiberTHuG


But since this is a client scripting forum and he was asking in a for a JavaScript solution....

Well it was an alternative suggestion/solution, like someone else mentioned PHP or Perl. If you look further down my original post, i have posted a Javascript Solution :)

da_silvy
Oct 17th, 2001, 02:12 AM
Originally posted by CiberTHuG

But since this is a client scripting forum and he was asking in a for a JavaScript solution....

This is not just a client side scripting forum

XML, HTML, Javascript, Web and CGI
Discuss XML, HTML, Javascript and popular CGI languages here. Topics include: Perl, PHP, Cold Fusion, and more. Note Java, ASP and VB Script have their own forums.


And we were just offerring alternative ideas

Crazy_bee
Oct 17th, 2001, 11:57 AM
Use frontpage's Feedback form. it has some buit in features to do what you want.

Zaphod64831
Oct 17th, 2001, 08:12 PM
Well, I got it figured out, somehow an onclick in the submit button works now. Here's the code:

In the header tag:

<script>
<!--
function submitIt()
{
var temp;
var tempstring;
tempstring = "<html><head><title>Thanks!</title></head><body text='#006600'><H1 align='center'>Thank you for your email.</H1><body></html>";
temp=window.open("","noname");
temp.document.write(tempstring);
}
-->
</script>


The Submit button:

<input type="submit" value="Submit" onclick="submitIt()">


I know it's not exactly a browser redirect, but hey, it works just fine )

Thanks for all the help guys!:D