Javascript replace value of input

you can not change the local variables by javascript while on-screen elements(HTML tag like input) we can change the value via javascript. To change the value in the local variable you have to assign value anyhow on the screen action.

Hi Filipe,

If you assign a value on basis of Js, there are two approaches you can follow 

i) If your using the script in any client action just set one Output parameter for the script with the respective value assigned, and assign that Output parameter to the local variable on the next step.

ii) If you're passing the value from web block using trigger event, In the event handler of the screen assign the local variable with the value.

Hope it helps!

Regards,

Saravanan Santhanam.

" If your using the script in any client action just set one Output parameter for the script with the respective value assigned, and assign that Output parameter to the local variable on the next step. "

The local variable and the input is in the screen, not in the webblock, in the webblock I have placeholders

Can you pls share any screenshot or sample oml to understand, how you set the value for the input widget?

Geting the objects

Javascript replace value of input

Setting the value:


As per the screenshot, I can understand your assigning value to the input in the Web block level. Since you don't have access to the screen's local variable, you need to trigger an event with an Input parameter and pass the value to the triggered event, In the handler client action of the screen just assign the value to the local variable.

Are you trying to do this for educational purposes ?

Because i am very curious as to why you want to resort to javascript for something OS offers you in client actions (which is better maintainable than JS).

No. I am trying to create a widget with the possibility of the input and textarea in the calling side. If you know how to do it with Outsystems client actions , please go forward, how to set inside the webblock something that is outside?

I am not sure what you mean by this. 

You can now access the value through the local variable, but this does not work for you?

I did create a formatmask for inputwidgets once. For his you need javascript, but even then i try to only use js to create events. And the logic i still put inside client actions and call them from js.

Are you trying something similar?

I think you didn't understand , the input is in a screen and the widget is a webblock (where I am trying to set the value of the input) , how do you access the local variable that is in the screen inside the webblock?

To have the input in your screen changed when something in your webblock changes, you can create an event and trigger it. then handle that event in your screen.

Example:

1: the input on the screen

2: the webblock.

and the raiseeventclick action in the webblock:

you can not change the local variables by javascript while on-screen elements(HTML tag like input) we can change the value via javascript. To change the value in the local variable you have to assign value anyhow on the screen action.

Description

Replace input text value by text in a string

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
function edValueKey(e)/*from  www  .  j av a2s. c  o  m*/
{
    var monTexte = 'This is my test';
    var my = document.getElementById("edValue").value;
    my = my.length + 1;
    document.getElementById("edValue").value = monTexte.substr(0, my);
    e.preventDefault();
}

       
    
   <body> 
      <input id="edValue" type="text" onKeyPress="edValueKey(event)">  
   

  • Previous
  • Next
  • Mask input text output from a form
  • Get the value of input in a div
  • Do calculation based on value input from form
  • Setting a form input value with Javascript
  • Show source code of HTML element on click to form input

Can change value in input JavaScript?

Change the Input Value Using the setAttribute() Function in JavaScript. We can also use the setAttribute() function instead of the value property to set the input value. We can also use the forms() function instead of the getElementById() or querySelector() function to get the element using the form name and input name ...

How do I change the input value of a file?

The only way to set the value of a file input is by the user to select a file. This is done for security reasons. Otherwise you would be able to create a JavaScript that automatically uploads a specific file from the client's computer.

How do you change the input value in HTML?

Input Text value Property.
Change the value of a text field: getElementById("myText"). ... .
Get the value of a text field: getElementById("myText"). ... .
Dropdown list in a form: var mylist = document. ... .
Another dropdown list: var no = document. ... .
An example that shows the difference between the defaultValue and value property:.

How do you reset input value?

Create a button..
Get the id of input field..
Set the value NULL of input field using document. getElementById('myInput'). value = ”.