i have three input. 1.input id: input1, 2. input id:input2 3. input id: input3.
i want to do this inputs input1 + input2 = input3
and my code like this but it’s not working.
i will share my code with you so you can tell me what is the problem.
$w.onReady (function () {
var input1 = $w("#input1").value;
var input2 = $w("#input2").value;
if (input1 === "") {
$w("#input3").value = "boş bırakmayın";
} else {
$w("#input3").value = input1 + input2;
}
setInterval("function()", 100);
});
Hey Recep,
Welcome to WixCode where great things happen.
Thank you for sharing your code and the screen shot. Now share with me the problem. What is happening, or not happening?
To help you figure out what’s happening, use console.log() to see what your code is doing - console.log() is your friend. Try this:
var input1 = $w("#input1").value;
console.log(input1);
var input2 = $w("#input2").value;
console.log(input2);
Good luck,
Yisrael
i try your solution it’s not help too
I want to aggregate Input1 and input2 and print to input3
console.log() isn’t a solution, it let’s you see what the values of your variables are in the Developer console.
What are you getting? Do you have anything on the screen. Is anything displayed in the Developer console?
I recommend reading Wix Code Basics to help you get started.
code screen :
preview screen display :
Could you edit and send my code like I want to do
Recep,
I tried your code on one of my pages and it works fine. The developer console shows that you have syntax errors in your code - that is, errors in the way that the code is writting. I don’t know what the rest of your code looks like so I can’t say what’s wrong.
Yisrael
so why it’s not working on my page ?
What is the URL for your site? I’ll take a look.
You have a number of problems.
The setInterval is causing a syntax error. You can learn more about setInterval here: Scheduling: setTimeout and setInterval .
The code that checks the input fields has nothing to do since when the page triggers the onReady() function, the fields are null or undefined. You will need to capture the input fields later - perhaps after clicking a button to submit the fields.
You should play with Tutorial: Creating a Form to Store User Input in a Database Collection
Furthermore, understand that if you are going to work with code, you will need to familiarize yourself with basic coding concepts to accomplish what you want. We are happy to get you pointed in the right direction and get you started with what the code should look like, but you’ll need to take it from there.
You can start learning with the Wix Code Basics .
Good luck
i am beginner. Could you send me the correct code? edit and send code for me
Hi,
Unfortunately we are not able to code your site in your behalf.
However you can easily fix your code by adding it inside the onChange event for your input boxes.
This way it will recalculate every time a user changes the input fields.
It should look similar to this:
export function input1_change(event, $w) {
var input1 = $w("#input1").value;
var input2 = $w("#input2").value;
if (input1 === "") {
$w("#input3").value = "boş bırakmayın";
} else {
$w("#input3").value = input1 + input2;
}
}
Feel free to post specific questions regarding code below.
I used the code you sent, but it did not work 