Hi, do you know how to define what input eventListener uses?
This is what I’ve tried to do but it doesn’t work:
Wix element (Input | #input1) //Here I input text
$w(‘#input1’).onInput(() => { //Some code to send the inputted text to HTML element
$w(‘#html1’).postMessage($w(‘#input1’).value);
})
HTML element (Embed HTML) (part of the content):
let text = document.querySelector(‘#theLabel’);
addEventListener(‘message’, event => {
if (event.id = “input1”) { //How to get the id (input1) of #input1
text.innerText = event.data
}
if (event.id = “input2”){
Then something else…
}
});
Sorry, I had to post it like this because this wouldn’t let me post it altogether.
Basically what I’m trying to achieve (the big picture) is that I have three fields: 1. Text field (you can write text). 2. Font option field (you can choose font from the list). 3. Font size field (you can choose font size from the list). And one output field that shows the written text with chosen font and font size.
So I haven’t evaluated all your code but you’re checking conditionals with a single = sign when you should be checking it with 3: ===
if (event.id = "input1")
should be:
if (event.id === "input1")
Hopefully that fixes it.