i am trying to enable/disable a textbox using a certain if-else using javascript

Can anyone help me with this. i am trying to enable or disable a textbox using a certain if-else condition based on the logged in user name such that the logged in username must be same as the profile name they are seraching for.If both matches than it will be enabled else disabled.How can we do this with javascript i outsystems?


Solution

Subham Bid wrote:

Can anyone help me with this. i am trying to enable or disable a textbox using a certain if-else condition based on the logged in user name such that the logged in username must be same as the profile name they are seraching for.If both matches than it will be enabled else disabled.How can we do this with javascript i outsystems?


Why you need JS for the same.

You can also do it by setting up the Enabled property of textbox. Set the Boolean flag value as per your condition in onReady[If Mobile] or Preparation [If WEB] Action & provide the flag to the Enabled Property.

Perhaps, If you still wanna go via JS approach then, Add a JS action & pass the Widget_ID to it.

Now set the document.getElementById.readonly property to true.

thanks,

Assif

 


Solution

Hi Subham Bid,

You can have the username stored in a screen local variable (UserNameVariable) and then cal a function when needed to check your matching condition. Take the next code as an example:

function disableTextBox() {
  if( UserNameVariable = 'John' ) ) {
     document.getElementById("TextBoxId").disabled = true; 
  }
}

Hi Subham,

Is it for mobile or web?

For Mobile just write your condition in enable property of text box.Like this.

Regards,

Thanks a lot.i got it

Subham Bid wrote:

Thanks a lot.i got it

Happy to know :)

Keep Going..

Thanks