Syswatch a écrit :
I have a problem, I need a small javascript, which checks if there is
any text in my textarea, and if it is NOT empty it should activate 2
radio buttons below.
It also has to check that one of these radio buttons is checked if they
are active.
soluce 1:
<textarea name="comment"
onchange="
document.getElementById('rad').style.display = this.value==''?
'none' : 'block';
if(this.form.comment_choice[0].checked) alert('yes');
else
if(this.form.comment_choice[1].checked) alert('no');
else alert('choice bellow');"></textarea>
<p id="rad" style="display:none">
yes ? <input type=radio name="comment_choice" value="yes">
no ? <input type=radio name="comment_choice" value="no">
</p>
soluce 2 :
<textarea name="comment"
onchange="
if(this.value=='') {
this.form.comment_choice[0].disabled = true;
this.form.comment_choice[1].disabled = true;
}
else {
this.form.comment_choice[0].disabled = false;
this.form.comment_choice[1].disabled = false;
}
if(this.form.comment_choice[0].checked) alert('yes');
else
if(this.form.comment_choice[1].checked) alert('no');
else
if(this.value!='') alert('choice bellow');"></textarea>
<br>
yes ? <input type=radio name="comment_choice" value="yes" disabled>
no ? <input type=radio name="comment_choice" value="no" disabled>
soluce 3 :
<textarea name="comment"
onchange="
var R1 = this.form.comment_choice[0];
var R2 = this.form.comment_choice[1];
if(this.value=='') {
R1.disabled = true;
R2.disabled = true;
}
else {
R1.disabled = false;
R2.disabled = false;
if(R1.checked) alert('yes');
else
if(R2.checked) alert('no');
else
alert('choice bellow');
}"></textarea>
<br>
yes ? <input type=radio name="comment_choice" value="yes" disabled>
no ? <input type=radio name="comment_choice" value="no" disabled>
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date