Ciao a tutti,
ho un form con all'interno due checkbox che devono essere flaggate entrambe per poter rendere il tasto invia cliccabile. Ma qualcosa non va perchè basta che ne flaggo una e il tasto Invia diventa attivo e cliccabile!
Vi posto il codice, come posso risolvere?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="it">
<head>
<script>
var checkobj
function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
var tempobj=checkobj.form.elements
if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
}
}
}
function defaultagree(el){
if (!document.all&&!document.getElementById){
if (window.checkobj&&checkobj.checked && window.checkobj2&&checkobj2.checked)
return true
else{
alert("Please read/accept terms to submit form")
return false
}
}
}
</script>
</head>
<body >
<br /><br />
<div align="center">
<form name="agreeform" onSubmit="return defaultagree(this)" action="">
<textarea class="codecontainer" rows="8" name="S1" cols="45" wrap="virtual">Accetta le condizioni</textarea><br>
<input name="agreecheck" type="checkbox" onClick="agreesubmit(this)"><b>Accetto</b><br />
<input name="agreecheck2" type="checkbox" onclick="agreesubmit(this)" />
<strong>Accetto
2</strong><br>
<input type="Submit" value="Submit!" disabled>
</form>
<script>
//change two names below to your form's names
document.forms.agreeform.agreecheck.checked=false
</script>
</div>
<br /><br /><br /><br /><br /><br />
<div align="center">
<a href="http://www.html.it"><img src="file:///C|/Documents%20and%20Settings/emarchesi/Desktop/logo_htmlit.gif" alt="JavaScript scaricato da HTML.it" border="0" width="50" height="50" /></a>
</div>
</body>
</html>
ho un form con all'interno due checkbox che devono essere flaggate entrambe per poter rendere il tasto invia cliccabile. Ma qualcosa non va perchè basta che ne flaggo una e il tasto Invia diventa attivo e cliccabile!

Vi posto il codice, come posso risolvere?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="it">
<head>
<script>
var checkobj
function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
var tempobj=checkobj.form.elements
if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
}
}
}
function defaultagree(el){
if (!document.all&&!document.getElementById){
if (window.checkobj&&checkobj.checked && window.checkobj2&&checkobj2.checked)
return true
else{
alert("Please read/accept terms to submit form")
return false
}
}
}
</script>
</head>
<body >
<br /><br />
<div align="center">
<form name="agreeform" onSubmit="return defaultagree(this)" action="">
<textarea class="codecontainer" rows="8" name="S1" cols="45" wrap="virtual">Accetta le condizioni</textarea><br>
<input name="agreecheck" type="checkbox" onClick="agreesubmit(this)"><b>Accetto</b><br />
<input name="agreecheck2" type="checkbox" onclick="agreesubmit(this)" />
<strong>Accetto
2</strong><br>
<input type="Submit" value="Submit!" disabled>
</form>
<script>
//change two names below to your form's names
document.forms.agreeform.agreecheck.checked=false
</script>
</div>
<br /><br /><br /><br /><br /><br />
<div align="center">
<a href="http://www.html.it"><img src="file:///C|/Documents%20and%20Settings/emarchesi/Desktop/logo_htmlit.gif" alt="JavaScript scaricato da HTML.it" border="0" width="50" height="50" /></a>
</div>
</body>
</html>