512
Views
5
Comments
Solved
i am trying to enable/disable a textbox using a certain if-else using javascript
Question

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?


2021-04-09 11-42-43
assif_tiger
 
MVP
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

 


2023-07-28 17-00-32
Marco Arede
 
MVP

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; 
  }
}
2024-05-22 10-21-41
Mohammad Hasib

Hi Subham,

Is it for mobile or web?

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

Regards,

UserImage.jpg
Subham Bid

Thanks a lot.i got it

2021-04-09 11-42-43
assif_tiger
 
MVP

Subham Bid wrote:

Thanks a lot.i got it

Happy to know :)

Keep Going..

Thanks


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.