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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    change form action on the fly?

    is there any way to change the action field in a form on the fly based on a button pressed? if so how can this done?

    <form>
    <input type="submit" name="yahoo" value="yahoo" onclick=this.form.action.value='yahoo.com';this.form.submit();>
    <input type="submit" name="google" value="google" onclick=this.form.action.value='google.com';this.form.submit();>
    </form>

    i am aware there that most people use form processing scripts, but doing this begins to cause alot of problems and doesnt follow the rules of the fusebox methodology i am using.

    thanks!

  • #2
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    isn't it just

    document.forms[0].action = "index.cfm";
    or
    this.form.action = "index.cfm";

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,030
    Thanks
    0
    Thanked 247 Times in 244 Posts
    You don't have to submit it as the button is already a submit button.
    Code:
    <form>
    <input type="submit" name="yahoo" value="yahoo" onclick="this.form.action.value='http://www.yahoo.com';" />
    <input type="submit" name="google" value="google" onclick="this.form.action.value='http://www.google.com';" />
    </form>
    If you are really submitting to an external site, you need to put http://


  •  

    Posting Permissions

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