alexz said:
Erwin Moller
Thank Erwin.
You would have an example of that javascript script?
Hi Alex,
I was being just a little ironical.
I did that because I thought your question was very vague.
Being ironical is not nice, so I'll make it up to you.
Two things:
1) Why I think your question is bad.
2) the solution to your problem (assuming I understood well).
1) Why is your question bad?
Because it was not clear what it is you cannot do.
Do you expect this newsgroup to give you some examplecode? Or is there some
particular thing you do not understand?
What is it that you cannot do?
Or what is it that doesn't work?
Do you not know how to get the state of a radiobuttun?
Do you not know how to use an if/else statement?
2) solution.
Because I am in a lot better mood than yesterday, here is the code to check
what you want.
I wrote is quit elaborately, to make clear how things work (I hope).
-------------------------------------
<html>
<body>
<script type="text/javascript">
function checkIt(){
var YesChecked = false;
var NoChecked = false;
var theFormRef = document.forms.myForm;
if (theFormRef.myRadioButton[0].checked) {
YesChecked=true;
if (theFormRef.fname.value.length>0) {
theFormRef.submit();
} else {
alert ("You forgot to fill fname!");
}
}
if (theFormRef.myRadioButton[1].checked) {
NoChecked=true;
if (theFormRef.lname.value.length>0) {
theFormRef.submit();
} else {
alert ("You forgot to fill lname!");
}
}
// checked anything?
if ((!YesChecked) && (!NoChecked)){
alert ("please check yes or no!");
}
}
</script>
<form name="myForm" action="somescript.php" Method="post">
<input type="radio" name="myRadioButton" value="Y"> Yes
<br>
<input type="radio" name="myRadioButton" value="N"> No
<br>
fname: <input type="text" name="fname">
<br>
lname: <input type="text" name="lname">
<input type="button" onClick="checkIt()" value="click me">
</form>
</body>
</html>