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

Recommended Answers

All 2 Replies

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.

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><br>
	<input type="radio" id="a2" name="a" onclick="setAction(this, 'myPage_2.html')"><label for="a2">Page 2</label><br>
	<!-- rest of your form ...... -->
</form>

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.