Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-23-2011, 11:10 AM   PM User | #1
Venice_Yan
New to the CF scene

 
Join Date: Sep 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Venice_Yan is an unknown quantity at this point
Need help in Redirecting

Hello everyone,

I have a code here:

<input type="submit" class="submitblog" onclick="document.getElementById('entry_draft').value=0; document.forms['frmNewBlog'].submit();return false;" value="Submit" />

How can i add a redirect page? I mean what is the code that i will add so that when my user click's submit, they will redirect to example.com/mypage

Thank you so much.

Ive been trying to figured it out but i have no luck at all... So i came up asking for help.
Venice_Yan is offline   Reply With Quote
Old 09-23-2011, 01:13 PM   PM User | #2
MtheGreat
New to the CF scene

 
Join Date: Sep 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
MtheGreat is an unknown quantity at this point
Hi,

You can put a <a href=""></a> tag around your code for your button, but then the onclick event in the button might not work.

so it would look like this:

<a href="page.you.want.to.link.to"> <input type="button"......./> </a>

hope this helps
MtheGreat is offline   Reply With Quote
Old 09-24-2011, 12:41 AM   PM User | #3
Venice_Yan
New to the CF scene

 
Join Date: Sep 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Venice_Yan is an unknown quantity at this point
Thank you for the reply. I got two input types. "Submit" and "Button". I tried to exclude my submit input type and just use the button input type, but still dont work.

Here is the code for my button input type:

<input type="button" class="submitblog" onclick="document.location='http://exampleofmypage.com/blog/entries'; return false;" value="Cancel"/>

My input button is use for "cancel"

Here is the code for the submit input:

<input type="submit" class="submitblog" onclick="document.getElementById('entry_draft').value=0; document.forms['frmNewBlog'].submit();return false;" value="Submit" />

Is there any way or any code i still can add in my submit input? So it will redirect?

Thank you so much.
Venice_Yan is offline   Reply With Quote
Old 09-24-2011, 03:40 AM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Despite the similar sounding names, Java is not the same as Javascript.
Moving from Java forum to Javascript forum.
Fou-Lu is offline   Reply With Quote
Old 09-24-2011, 07:51 AM   PM User | #5
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,036
Thanks: 197
Thanked 2,411 Times in 2,389 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by Venice_Yan View Post
How can i add a redirect page? I mean what is the code that i will add so that when my user click's submit, they will redirect to example.com/mypage
You can't with Javascript. The submit refreshes/reloads the page. You need to use server-side scripting.
The redirect after submit should be done in the PHP document which is the target of the form submission.

document.location is an invalid object reference. That should be window.location

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

Last edited by Philip M; 09-24-2011 at 08:00 AM..
Philip M is online now   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:46 AM.


Advertisement
Log in to turn off these ads.