|
-
Jan 31st, 2001, 07:51 PM
#1
Thread Starter
Hyperactive Member
Alright, I've tried everything I could think of, but I just can't get this to work for me.
How can I use Javascript to both redirect the browser and submit a form when a button is pressed?
-
Jan 31st, 2001, 11:27 PM
#2
PowerPoster
Well, it depends. The easiest way to do it would to just use regular html and the action property to submit the form, and then have the file that you submit the form data to redirect the user, if you wanted javascript to do both, you could accomplish this with a function.
Another way that you could do it is to do something like this:
< input type="submit" value="submit" onClick="reditect();" >
since the type is a submit button, it will automatically submit the form, then all you have to do is call the redirect function to finish off the job.
I hope that helps, if you need more help, i could give a sample.
-
Feb 1st, 2001, 06:10 PM
#3
Thread Starter
Hyperactive Member
I did that, here's what I have:
Between the header tags:
Code:
<SCRIPT LANGUAGE="Javascript">
<!--
function Clicked()
{
location.href="http://www.olemac.net/~hutch"
}
-->
</SCRIPT>
Then in the form:
Code:
code...
<input type="submit" value="Submit" OnClick="Clicked();">
code...
What am I doing wrong?
-
Feb 1st, 2001, 06:38 PM
#4
PowerPoster
you are on the right track. I am assuming that what you are having problems with is the URL redirection.
Remember that location is a property of the window, so write it like this:
Code:
window.location.href='your url';
also, if you want to simplify it even more, you can eliminate the function, and simply put the URL redirect within the onclick itself, like this:
Code:
onClick="window.location.href='your url'";
i hope that helps...
If you have any questions let me know
-
Feb 1st, 2001, 07:30 PM
#5
Thread Starter
Hyperactive Member
My submitbutton now contains:
Code:
<input type="submit" value="Submit" OnClick="window.location.href='http://www.olemac.net/~hutch';">
Still won't work though...
-
Feb 1st, 2001, 07:32 PM
#6
New Member
what doesn't work? could you explain a little more?
-
Feb 1st, 2001, 08:00 PM
#7
Thread Starter
Hyperactive Member
Ok, here's the really in-depth, nothing left out description:
I have a feedback form, and when the user clicks on it it mails the contents directly to me. But I keep getting multiple emails because people don't know for sure that the form sent. Therefore I need something that will redirect them to a "Thank you" page when they click the button. I once found something that would do this but it wouldn't submit the form so I need some way to do both.
-
Feb 1st, 2001, 11:23 PM
#8
PowerPoster
Are you having problems getting it to work in NN? Another thing that you may want to try is the onSubmit which can be used in the form tag.
Code:
<form onSubmit="myfunction()" method="post">
-
Feb 2nd, 2001, 11:01 AM
#9
Could it have to do with the location of the semicolon ";"?
-
Feb 2nd, 2001, 05:34 PM
#10
PowerPoster
what? after the window.location="whatever"? No that wouldn't matter.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|