Forum Moderators: open

Message Too Old, No Replies

changing CSS for disabled form elements

changing CSS for disabled form elements

         

drengur

10:08 pm on Oct 3, 2005 (gmt 0)

10+ Year Member



hi there,
I am modifying an existing page and need to restyle disabled items (as thay have already been styled via CSS)
I am trying to write a function that will both set a form input to disabled AND change it's classname.
This is what I have so far:-

function showcontime(){
if (document.frm.phone.checked){
document.frm.ConTimes.disabled=false&&
document.frm.ConTimes.className=input;
}
else{
document.frm.ConTimes.disabled=true;
}
}

that will change it to disabled but it won't change the style.
Fairly new to javascript by the way!

Thanks in advance!

drengur

12:53 am on Oct 4, 2005 (gmt 0)

10+ Year Member



By the way, I am getting errors in the javascript console saying that

Error: frm is not defined

however the form's name is the same (including case)

I can post html if needed as well!

drengur

4:21 am on Oct 4, 2005 (gmt 0)

10+ Year Member



Well I found a solution elsewhere but I will post here for others:-

function unlockbox(){
if (document.form1.checkboxname.checked){
document.form1.lockedboxname.disabled=false;
document.form1.lockedboxname.className='input';
}
else{
document.form1.lockedboxname.disabled=true;
document.form1.lockedboxname.className='disabled';
}
}

in the head.
then in the body, we have:-


<form name="frm" method="post">
<input type="checkbox" name="checkboxname" onClick="unlockbox()" />
<input disabled name="lockedboxname" type="text" class="disabled" />