Forum Moderators: open

Message Too Old, No Replies

Javascript

Working with 'IF' conditions

         

Viji

9:31 am on Apr 27, 2009 (gmt 0)

10+ Year Member



Hi I am new to Javascript but got struck with a simple logic.Please help me if you can!

I have created three checkboxes 0,1,2 in ASP and calling a function ('one') in JS.

The condition is while I check the checkbox '2',the checkboxes '0' and '1' sould turn false.

Also, when I check the checkboxes '0' and '1', the checkbox 2 should turn false.

While I use the code below, it occurs like
"When I check checkbox '2' and then check '0' and '1' it works fine. THe checkbox '2' is set to false and I can check only '0' or '1'. But if I check '0' or '1' and then 2, am not able to check it and '0' and '1' doesnt get turned to false.

Kindly anyone help me out of this simple issue which is hitting me!

function trial()
{
if ((frmMain.ChkQuest(0).checked) ¦¦ (frmMain.ChkQuest (1).checked))
{
if (frmMain.ChkQuest(2).checked)
{
frmMain.ChkQuest(0).checked = false;
frmMain.ChkQuest(1).checked = false;
}
}
if (frmMain.ChkQuest(2).checked)
{
if ((frmMain.ChkQuest(0).checked) ¦¦ (frmMain.ChkQuest(1).checked))
{
frmMain.ChkQuest(2).checked = false;
}
}
}

daveVk

11:45 am on Apr 27, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your description say "when I" yet the function takes no account of the history of events.

The function can detect the bad state,
bad = ( c0 ¦¦ c1 ) && c2;
but can not determine the correct action to take without the history of the last action.