Expand my Community achievements bar.

SOLVED

Make a texfield readonly with drop down list.

Avatar

Level 2

Hello all,

I have an form with a drop down list in it. I want that if the value in the list is "yes" that you can put some text in the textfield below it. But if the value is "no" the textfield must be readonly and not chageable.

I've bind the text to variable 1 and 2

object.jpg

I've tried/made the following script but is doesn't work, but it's also giving no error.


form1.#subform[0].dropdownlist2[0]::click - (JavaScript, client)



if

(this.rawValue == 1)

{

// Open Field

     Textfield1.access = "open";

 

}

else


{


//Block field

     Textfield1.access = "ReadOnly";


}



Greetings,

Timo

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Timo,

I now see that the script is in the click event. This is not a good choice for dropdowns as the selected value is not committed yet.

If you move the original (corrected) script to the exit event, it will work as expected.

Good luck,

Niall

View solution in original post

4 Replies

Avatar

Level 10

Hi,

Nearly there: the read only syntax is a lowercase 'r':

...

Textfield1.access = "readOnly";

Hope that helps,

Niall

Avatar

Level 2

Hi Niall,

It helps that the textbox is now readonly whit option 1.

In the image you can see the text "wel een" witch means yes and "geen" witch means no. And now he makes the textbox read only if I fill in "yes" witch is binded to "1".

Really weird.

Greetings,

Timo

Edit://

I changed the "open" and "readOnly" acces and now it works. But that can't be correct. Now i say in the script that if I fill in "yes" that the textbox must me read only.

Is it also possible to erase the input in the textfield if option 2 is selected?

Avatar

Correct answer by
Level 10

Hi Timo,

I now see that the script is in the click event. This is not a good choice for dropdowns as the selected value is not committed yet.

If you move the original (corrected) script to the exit event, it will work as expected.

Good luck,

Niall

Avatar

Level 2

Okay,

Thanks, it works now.

Greetings,

Timo