CreativeMind wrote:
i have following code but problem is that when i debug both checkboxes
have disabled property always false whether it is checked or
unchecked..thx for help.
function checkFinance(){
var
chk1=document.getElementById("_ctl0_ContentPlaceHo lder2_chkFinance");
var
chk2=document.getElementById("_ctl0_ContentPlaceHo lder2_chkMortgage");
var
cbo1=document.getElementById("_ctl0_ContentPlaceHo lder2_ddlFinance");
var
cbo2=document.getElementById("_ctl0_ContentPlaceHo lder2_ddlMortgage");
var cbo1val=cbo1.value;
var cbo2val=cbo2.value;
These two variables are unnecessary, and performance would also improve
slightly if you used the references right-hand side only when they are needed.
if(!chk1.disabled){
I suppose you meant
if (!chk1.checked)
{
cbo1.value=cbo1val;
That does not make sense to me.
cbo1.disabled=true;
}
else
{
cbo1.disabled=false;
}
cbo1.disabled = !chk1.checked;
would suffice, and it would be more efficient and easier to maintain.
if(!chk2.disabled){
if (!chk2.checked)
{
cbo2.value=cbo2val;
See above.
cbo2.disabled=true;
}
else
{
cbo2.disabled=false;
}
cbo2.disabled = !chk2.checked;
return true;
}
As for the rest of your code, you should be using the `elements' collection
of form objects instead of several document.getElementById() calls. And you
would probably need a server-side alternative that double-checks the
submitted data.
HTH
PointedEars
P.S.
The pronoun `I' and the first letter of a sentence must be a capital letter
in proper English.
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee