enable textbox on change of combo box value

enable textbox on change of combo box value

  

Hi Guys - I want to enable my textbox based on the value of combo box, so I have this code here, which seems ok and it worked in my C# app as well but not in OutSystems. 

SyntaxEditor Code Snippet

"if(document.getElementById('"+Application_ServiceHours.Id+"').value==3)
{
alert(document.getElementById('"+Application_ServiceHours.Id+"').value);
document.getElementById('"+Application_Txt_ServiceHours.Id+"').disabled = false;

}
"

I can get the alert as well for the value which it says '3' which is correct but it's just not setting the other text box enabled, any clue?

Cheers,

Solution

Sandeep, 

The other quick way is to set a variable to the enable property of text box , set it true or false based on Dropdown selection (OnChange Action) and refresh the text box .

Regards

-PJ-

Solution

Pramod Jain wrote:

Sandeep, 

The other quick way is to set a variable to the enable property of text box , set it true or false based on Dropdown selection (OnChange Action) and refresh the text box .

Regards

-PJ-

Hi Pramod - well that's what I have done. set the textbox Enabled=false.


and OnChange of combo box put this logic, to enable the textbox.


But I don't know how to refresh Textbox via Javasscript?

Also just to debug it I have put alers there but no mattter what value I set up for the textbox's enable property i.e. true or false it always shows me disabled=false in my alerts. WHY???? 

SyntaxEditor Code Snippet

"if(document.getElementById('"+Application_ServiceHours.Id+"').value==3)
{
alert(document.getElementById('"+Application_Txt_ServiceHours.Id+"').disabled);
document.getElementById('"+Application_Txt_ServiceHours.Id+"').disabled = false;
alert(document.getElementById('"+Application_Txt_ServiceHours.Id+"').disabled);
}
"

 

Sandeep,

It seems that you are unnecessarily making your application complex by adding Javascript code.

What Pramod is telling that you should have one local variable of boolean type. 

Assign that boolean variable to Enabled property of text box.

Onchange  event of  combobox assign that variable value as True and after that use Ajax refresh control. In ajax refresh, you should give widget of textbox which you want to enable and your textbox will be anabled.







Hope this helps.

Thanks and Regards,

Suraj Borade

Hi Sandeep ,

Suraj described it very clearly , just follow that .



Regards

-PJ-

Thank you Pramod for your idea and Suraj for your explanation with the figures, it really helped and works like a charm. 

Cheers