cancel
Showing results for 
Search instead for 
Did you mean: 

JavaScript for disabling htmlb elements

Former Member
0 Kudos

Hello,

in my bsp application i want to change the attribute disabled of htmlb:inputfields and htmlb:dropdownlistbox. I used following javascript:


document.getElementById('controllerID_inputfieldID').disabled = 'true';
document.getElementById('controllerID_inputfieldID').disabled = '';

This isn't work right, because the disabled is displayed other than I set disabled in the htmlb tag (<htmlb:inputField id = "inputfieldID" disabled = "true") and I can choice a element in the dropdownlist.

What is the correct javascript function for disabling htmlb elements?

Tina

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

hello,

Dont put value true in qoutes.

try like this:

document.getElementById("user1").disabled = true;

Regards,

Niky

Former Member
0 Kudos

Hi Niky,

thanks for your answers. But it doesn't help, because the elements aren't disabled.

Maybe there is an other way, to solute my problem?

I have 2 htmlb:radioButton's. If I select one of this, the other radio button, some input fields and a htmlb:dropdownListBox should be disabled. How I get this?

Thanks in advanced,

Tina

Former Member
0 Kudos

Hi,

I am using:

var ifield=document.getElementById('controllerID_inputFieldID');
ifield.disabled=true;
ifield.className=ifield.className.replace("Enbl","Dsbl");

It works with me for input fields and list boxes.

Regards,

Tanguy

Former Member
0 Kudos

Hi Tanguy,

thanks for answering.Your code working like my code in my question (my first entry):

The inputfield and dropdownbox looks like disabled, but the dropdownbox isn't really disabled. I can choice an element.

Tina

Former Member
0 Kudos

I believe that the following will work for you, although I must caution that it is not likely supported by SAP. Any service pack upgrade or patch may break this code. Use at your own caution.

This is from a function that can disable or enable different objects using Javascript. Setting the st attribute seems to be what it takes to make it readOnly. Setting the class just applies the disabled look.


      case "DROPDOWN":
        switch(mode)
        {
          case "DISABLED":
            window.document.getElementById(ID).st = "r";
           window.document.getElementById(ID).className = "urCoB2TxtDdl urCoB2Ro";
            break;
         case "ENABLED":
            window.document.getElementById(ID).st = "";
            window.document.getElementById(ID).className = "urCoB2TxtDdl";
           break;
       }
       break;

Former Member
0 Kudos

try the following code

document.getElementById('input field id').style.disabled="true";

reward points if useful.....

Former Member
0 Kudos

Hi Naresh ,

I tryed yours. If I used this whitout "controllerID" I get an error, because it couldn't find the object (controllerID is needed, because I use MVC and Subcontroller).

If I used yours with controllerID, there is happend nothing. No error, no disabling.

Former Member
0 Kudos

Hi,

try with inputfieldID only

grtz,

Koen

Former Member
0 Kudos

Hi Koen,

thank for the quick answer.

If I try this with only inputfield ID I get an javascript errror. I need the controller ID, because I used MVC and different subcontroller.

Tina