954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Different action in different radio button ??

Hi all,

I am making a form in which i am using two radio button.Now i want that if i click on first radio button and after that i will click on submit button then page should go different page .
If i click on 2nd radio button and after that i submit page then page should go on different page.

Please help me to solve this. How i can do this if it is possible.
thanks

gagan22
Junior Poster
131 posts since Feb 2009
Reputation Points: 10
Solved Threads: 0
 

What you could do, is on the submit function of your button, check which radio button was selected, then change the value of the form action attribute.
for the changing of the value of the form action:

document.formName.action ="whever u want it to go"


formName is the name of your form.

Thirusha
Posting Whiz
357 posts since Mar 2008
Reputation Points: 36
Solved Threads: 57
 

Gagan22,

<script>
function setAction(r, url){
	r.form.action = url;
	r.blur();
}
</script>
<form name="myForm" action="myPage_1.html" method="post">
	<input type="radio" id="a1" name="a" onclick="setAction(this, 'myPage_1.html')" checked="checked"><label for="a1">Page 1</label>
	<input type="radio" id="a2" name="a" onclick="setAction(this, 'myPage_2.html')"><label for="a2">Page 2</label>
	<!-- rest of your form ...... -->
</form>


Airshow

Airshow
WiFi Lounge Lizard
Moderator
2,683 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You