Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Despite the similar sounding names, Java is not the same as Javascript.
    Moving from Java forum to Javascript forum.

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    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.
    Last edited by Philip M; 09-24-2011 at 08:00 AM.

    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •