SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: Form Action
-
Apr 9, 2005, 09:06 #1
- Join Date
- Oct 2004
- Location
- Wales
- Posts
- 25
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Form Action
Hi woundering if anyone can give me a hand. I have a form with 2 submit buttons and want different actions based on what button is clicked. I set an action on the form which was used when the first button was click but had onClick="setAction()" to call the following JS function to set the form action when the second was pressed:
Code:function setAction(){ document.formName.action='alternate action'; document.formName.submit(); }
-
Apr 9, 2005, 09:43 #2
- Join Date
- Nov 2004
- Location
- Parry Sound, ON
- Posts
- 725
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Think maybe you just need to return false.
Code:function setAction(){ document.formName.action='alternate action'; document.formName.submit(); return false; }
-
Apr 9, 2005, 10:14 #3
- Join Date
- Oct 2004
- Location
- Wales
- Posts
- 25
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks anyway but didn't work
-
Apr 9, 2005, 11:15 #4
- Join Date
- Nov 2004
- Location
- Parry Sound, ON
- Posts
- 725
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Works for me:
HTML Code:<html> <head> <script type="text/javascript"> function setAction(){ document.formName.action='http://www.yahoo.com/'; document.formName.submit(); return false; } </script> </head> <body> <form name="formName" action="http://www.google.com" method="get"> <input type="submit" value="Google" /> <input type="submit" value="Yahoo" onclick="setAction();" /> </form> </body> </html>
-
Apr 9, 2005, 12:33 #5
- Join Date
- Oct 2004
- Location
- Wales
- Posts
- 25
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks I got it. There was a hidden form fields called action to and seems to be causing IE probs
Bookmarks