Mel wrote:
I have a form with 2 submit buttons (s1 s2) and a list of checkboxes
this is what i want to do:
on a single checkbox select:
i want to display s1
on two or more checkbox selection:
i want to display s2 & hide s1
can you please help ? a simple example is highly appreciated
Here is the code:
<html>
<head>
<script language="javascript">
function f_button() {
numberchecked = 0
for(x=0;x<document.myform.length;x++)
if(document.myform.elements[x].type=='checkbox'
&& document.myform.elements[x].checked)
numberchecked++
if (numberchecked==0) {
document.getElementById("button1").style.visibilit y='hidden'
document.getElementById("button2").style.visibilit y='hidden'
document.getElementById("button1").style.display=' none'
document.getElementById("button2").style.display=' none'
}
if (numberchecked==1) {
document.getElementById("button1").style.visibilit y='visible'
document.getElementById("button2").style.visibilit y='hidden'
document.getElementById("button1").style.display=' inline'
document.getElementById("button2").style.display=' none'
}
if (numberchecked>1) {
document.getElementById("button1").style.visibilit y='hidden'
document.getElementById("button2").style.visibilit y='visible'
document.getElementById("button1").style.display=' none'
document.getElementById("button2").style.display=' inline'
}
}
</script>
</head>
<body>
<form name="myform" method="get" action="myscript.php">
<input type="checkbox" name="c1" value="1" onClick="f_button()">
<input type="checkbox" name="c2" value="1" onClick="f_button()">
<input type="checkbox" name="c3" value="1" onClick="f_button()">
<input type="checkbox" name="c4" value="1" onClick="f_button()">
<input type="checkbox" name="c5" value="1" onClick="f_button()">
<hr>
<input id="button1" type="submit" value="s1"
style="visibility: hidden; display: none">
<input id="button2" type="submit" value="s2"
style="visibility: hidden; display: none">
</form>
</body>
</html>
--
Bart