|
-
Feb 13th, 2001, 02:36 PM
#1
can't figure out why the #&@ this doesn't work:
if (!(frmMan.chkDis.checked))
{
alert("Please indicate a Discipline.");
frmMan.chkDis(0).focus();
return false;
}
else
{
return true;
}
Any help would be greatly appreciated!!
whether the radios are selected or not it performs the if and not the else.
-
Feb 13th, 2001, 03:29 PM
#2
Hyperactive Member
Code:
if (frmMan.chkDis.checked)
{
return true;
}
else
{
alert("Please indicate a Discipline.");
frmMan.chkDis(0).focus();
return false;
}
how about that?
-
Feb 13th, 2001, 04:07 PM
#3
The old negative routine hunh!
Tried inverting this, sama ting it always gives me the else now and not the if. Any other ideas?!!
-
Feb 13th, 2001, 04:09 PM
#4
The old negative routine hunh!
Kagey, thanks for the post I tried inverting this, sama ting it always gives me the else now and not the if. Any other ideas?!!
-
Feb 13th, 2001, 06:22 PM
#5
Hyperactive Member
Is this a set of radio buttons, or a checkbox? if it is a set of radio buttons, try this for the if statement:
Code:
if (frmMan.chkDis.value = "")
{
return true;
}
else
{
alert("Please indicate a Discipline.");
frmMan.chkDis(0).focus();
return false;
}
-
Feb 14th, 2001, 08:16 AM
#6
reversed
Kagey, thanks again I took your code and cut and pasted it results are the same it now performs the else no matter wether the radio button is checked or not. Inverting this gives me the same result it performs the if statement and never performs the else, thanks.
-
Feb 14th, 2001, 10:39 AM
#7
Frenzied Member
it's far from clear waht it is you are trying to do.
Are you testing to make sure that at least one radio button id checked?
If so, this might help:
Code:
<HTML>
<HEAD>
<script language=javascript>
function doit()
{
var r
for(i=0;i<=4;i++)
{
r |= document.frm1.radio1(i).checked
}
if(r==0)
alert("Please indicate a Discipline.");
}
</script>
</HEAD>
<BODY>
<form name=frm1>
<INPUT id=radio1 name=radio1 type=radio><BR>
<INPUT id=radio1 name=radio1 type=radio><BR>
<INPUT id=radio1 name=radio1 type=radio><BR>
<INPUT id=radio1 name=radio1 type=radio><BR>
<INPUT id=radio1 name=radio1 type=radio><BR>
<input type=button onclick="doit()">
</form>
</BODY>
</HTML>
-
Feb 14th, 2001, 01:00 PM
#8
Thanks
Thanks Mark!!!
Looks like that is exactly what I needed, I went to cnet and found an article from Charity Kahn I redid her code at http://builder.cnet.com/Programming/Kahn/042298 and it got me squared away here thanks alot!!!!
final code looked like this:
function deptChecked(form) {
for (i=0; i<form.chkDis.length; i++) {
if (form.chkDis[i].checked) {
return true;
}
}
return false;
}
function validateForm(form)
{
if (frmMan.frmComment.value == "")
{
alert("Please give us your comments concerning this Lesson.");
return false;
}
if (!deptChecked(form))
{
alert("Please indicate a Discipline.");
return false;
}
else
{
return true;
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|