Hello, I have the following problem: I need certain input fields of a window that I open from a button of a form to show certain values of some fields of that first form. As I need to show these values when the window is opened, I have thought to put the code in the event of the button of the form, but I do not know how to call the fields of the window, since they are not in the same form and I need to indicate that they are fields of the window. Does anyone know how to do it? Thank you.
Hello Exceed,
For this it looks like you would have to use local storage to store the input values of the first form in the browser. This can be done on keypress or on opening of the second form (button click in your case).
Here is an example of what the code would look like
import {local} from 'wix-storage';
...
$w.onReady(() => {
//everytime the user presses a key on any of the input fields, it is stored in local in the browser
$w('#input1').onKeyPress(() => {
local.setItem("input1", $('#input1').value);
})
$w('#input1').onKeyPress(() => {
local.setItem("input2", $('#input2').value);
})
$w('#input1').onKeyPress(() => {
local.setItem("input3", $('#input3').value);
})
//When you press the button the window is shown, then it gets the values in the local storage and ````//fills them out
$w('#formOneSubmitButton').onClick(() => {
$W('#window').show().then(() => {
$w('inputValueOfWindow1').value = local.getItem('input1');
$w('inputValueOfWindow2').value = local.getItem('input2');
$w('inputValueOfWindow3').value = local.getItem('input3');
})
})
})
Some useful links:
Keypress Event,
Show,
Local storage
Goodluck,
Majd
Thank you very much, your advice has helped me a lot. I have managed to do what I wanted, even though if I change OnkeyPress to Onchange, because OnkeyPress does not pick up a character if after it the focus of the mouse is simply changed to another field.