Click to See Complete Forum and Search --> : Radios and Alert


Tricky123
12-18-2002, 12:27 PM
Hi,

Is it possible to have a different alert for each radio item within a group of radios - If so how?

TIA

swon
12-18-2002, 12:45 PM
Maybe you're searching for something like that:

<html>
<script language="JavaScript">
<!--
function checkit(form){

var myform = form.elements.length -1;
for(i=0;i<myform;i++)
{
if(form.elements[i].checked==false)
{
title = form.elements[i].getAttribute("title");
alert("The radio named "+ title +" isn't checked");
}
}
}
//-->
</script>
<body>
<form action="" method="post"onSubmit="return checkit(this)">
<input type="Radio" name="myradio" value="1" title=Radio1>
<input type="Radio" name="myradio" value="2" title=Radio2>
<input type="Radio" name="myradio" value="3" title=Radio3>
<input type="Submit" name="test it" value="">
</form>
</body>
</html>

Tricky123
12-18-2002, 12:58 PM
Thats very good, thanks!

Now for your next problem...

when I submit my form I want to submit a value of checked or not-checked for all the radios - so I get a value even if they were not checked.

(there can be as much useful information gained from a non-selection as for a selection!!)

Thanks!