Posts: 256
Location: Auckland, New Zealand
|
You seem to be using Javascript and not PHP.
It's always a good idea to check clientside but the same checks should be done serverside too.
I'll just write some HTML with Javascript showing a possible way of doing it, I'm not sure if this would be how I would do it but it'd give you some idea of what you could do.
HTML Code:
<!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>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
<title>Javascript Radio Validation</title>
<script type="text/javascript">
//<![CDATA[
function validateRadio()
{
var yes = null;
var no = null;
with(document)
{
yes = getElementById('confirmYes');
no = getElementById('confirmNo');
}
if(yes.checked && yes.value == 'yes')
{
alert('yes is checked');
return true;
}
else if(no.checked && no.value == 'no')
{
alert('no is checked');
return true;
}
else if(!(yes.checked || no.checked))
{
alert('nothing is checked');
return false;
}
else
{
alert('how did it get to this?');
return false;
}
}
//]]>
</script>
</head>
<body>
<form action="" method="post" onsubmit="javascript:validateRadio();">
<div>
<label for="confirmYes">Yes <input id="confirmYes" name="confirmation" type="radio" value="yes" /></label>
<label for="confirmNo">No <input id="confirmNo" name="confirmation" type="radio" value="no" /></label>
<br />
<input id="submit" name="submit" type="submit" value="Submit" />
</div>
</form>
</body>
</html>
Hopefully that covers what you're looking for, if you have any questions about this then do ask. If you'd like to know how to verify the results using PHP too, then ask and I'll include that too.
Cheers,
MC
__________________
#------------------------------ signature---------------------------------------------------------------------------------#
Quote:
|
I am well recognised for what I don't do than what I do. Chores are just one of those things.
|
Last edited by mastercomputers; 07-12-2006 at 11:06 PM..
|