PDA

View Full Version : Help on where to submit the page depending on Radio Button Check


wty
01-03-2003, 06:09 PM
Hi,

I need to submit a form depending on the check of a radio button. Does anyone have some code examples for that purpose?

Thanks!

wty

whammy
01-03-2003, 11:15 PM
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title>Radios</title>
<script type="text/javascript">
<!--
function checkanswer(radios) {
var checkflag = false;
var i = 0;
var radlen = radios.length;
while (i < radlen && !checkflag) {
if (radios[i].checked) checkflag = true;
i++;
}
checkflag == true ? void 0 : alert('Please choose an answer!');
return checkflag == true;
}
// -->
</script>
</head>
<body>
<div>
<form id="blah" action="radios.htm" onsubmit="return checkanswer(this.answer)">
<input type="radio" name="answer" value="1" />1<br />
<input type="radio" name="answer" value="2" />2<br />
<input type="radio" name="answer" value="3" />3<br />
<input type="radio" name="answer" value="4" />4<br />
<input type="radio" name="answer" value="5" />5<br />
<input type="submit" value="Submit" />
</form>
</div>
</body>
</html>


Hope this helps! :D

wty
01-04-2003, 11:54 PM
Hi whammy,

Thanks for replying to me!!!

My question was try to determine where to send the form depending on which radio button was checked, instead of whether to send. I couldn't get it to work because I was trying to send the form based on the input from the same form.

I finally got it work by sending the form to another form where I decide the future destination based on the value recceived from the previous form.

Thanks again!

wty