Unable to Retrieve Input Value

Hi all!

I have a fairly basic issue on a Dynamic Page. Basically I have an input field (let’s call it input1). Now when I set the value of input1 to say, “HELLO WORLD” using a function called in the onReady function, the value of input1 displays as “HELLO WORLD” (all good so far!)

The issue occurs later when trying to retrieve that value. Basically, if I want to “read” the value of input1 on a button press to see if it has any value, no value displays. Using a console.log($w(“#input1”).value), the console logs an empty value even though the page is displaying the correct “HELLO WORLD” value.

Is this an issue with inputs on Dynamic Pages only? Adding a setTimeout of over 1.5 seconds does fix the issue (usually), but that is way to clunky to work as a solution.

Any advice is very welcome!

No actually its not a dynamic page issue, it is apparently a bug with all input fields. So unless the user takes their cursor over the input box and clicks on it, the input does not consider it as the value you’ve set by code.

I was facing the same issue but I managed to solve it using a simple workaround.

Try calling the $w('#input').focus(); after assigning a value to the input or before reading the value of that input. This should solve the issue.

1 Like