Expand my Community achievements bar.

SOLVED

Why doesn't making a textbox read only based on drop down work?

Avatar

Level 2

Hello experts.

I received help on this just a few minutes ago, and it worked just fine so I closed the discussion and the form.  However, now it no longer works and I don't know what I did.   

I have a form with a dropdown list and two text boxes.  The first text box is populated based on the value selected in the dropdown list, I used a simple array to do this and it works as intended.  I needed to make textbox2 read only based on certain selections in the drop down field.  This worked just fine at first, but now it no longer works.  I haven't made any changes to the form except that I have closed and saved it since. 

I am trying to get the following to work:

if(this.rawValue=="Junk Again ")

{textbox2.access="readOnly";}

if(this.rawValue=="More Junk ")

{textbox2.access="readOnly";}

I placed this into the change event using javascript.  I am using ES 8.2 on Windows Vista 32bit.

Any help would be greatly appreciated.

Thanks,

Jerald

1 Accepted Solution

Avatar

Correct answer by
Level 10

In the change event you can not get the rawValue.. So use xfa.event.newText to get the changed text..

Also you have one space at the end of the value while comparing. In the below code I removed it.

if(xfa.event.newText == "Junk Again")

     {textbox2.access="readOnly";}

if(xfa.event.newText == "More Junk")

{textbox2.access="readOnly";}

Thanks

Srini

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

In the change event you can not get the rawValue.. So use xfa.event.newText to get the changed text..

Also you have one space at the end of the value while comparing. In the below code I removed it.

if(xfa.event.newText == "Junk Again")

     {textbox2.access="readOnly";}

if(xfa.event.newText == "More Junk")

{textbox2.access="readOnly";}

Thanks

Srini