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 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2008
    Location
    Arganda, Madrid, Spain
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    onclick="setAction(..." does not redirect

    Hello
    I have this really simple form.

    <form name="cac" id="cacid" method="POST">
    <input type="submit" value="Go to google"
    onclick="setAction('http://www.google.es')"/>
    </form>

    Why doesn't it go to www.google.es when the submit button is clicked?Thanks in advance

  • #2
    New Coder
    Join Date
    Sep 2008
    Location
    Arganda, Madrid, Spain
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Solved

    Quote Originally Posted by thosecars82 View Post
    Hello
    I have this really simple form.

    <form name="cac" id="cacid" method="POST">
    <input type="submit" value="Go to google"
    onclick="setAction('http://www.google.es')"/>
    </form>

    Why doesn't it go to www.google.es when the submit button is clicked?Thanks in advance
    Solved, the id was not correct according to my javascript function:
    function setAction(action)
    {
    var txt="";
    try{
    document.getElementById('cac2id').action = action;
    }catch(err){
    txt = "Error in function setAction() with description:" . err.description;
    alert(txt);
    }
    return true;
    }
    Therefore, I just put cac2id in the id tag and it is solved.


  •  

    Posting Permissions

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