Change iFrame src dynamically

What I’m trying to do
I want to change the code of an iFrame dynamically, using a user’s input, after they press ‘submit’.

What’s happening instead
I read three questions on this and answers by Yisrael and Ziv, spent an hour debugging, but sadly I can’t seem to get this to work. There doesn’t seem a way to change the code of an iFrame.

My code
Below is a sample of the code (input names changed for simplicity).
User enters a parameter in text box ‘userinput’, which I then try to set as part of the new code for an iFrame (myiframe).

After pressing the button, Debug1 shows correctly the new source. Debug2 shows the source returned from the iFrame. But sadly Debug2 always shows me a URL rather than the actual code that I set.

What am I doing wrong?

export function submit_click(event, $w) {

let newsrc = '<iframe src=\"https://www.mywebsite.com=' + $w("#userinput").value + '\" ></iframe>';

$w("#debug1").text=newsrc;
$w("#myiframe").src = newsrc;

$w("#debug2").text= $w("#myiframe").src ; 
}

Hey
The src parameter is just the url not the iframe and so on. So if you just set the src to https://www.mywebsite.com=’ + $w(" #userinput ").value it should work better.

Hi Andreas. Thank you so much. I didn’t realise it. It works like a charm now!

For people who had the same problem, my mistake was in the ‘let newsc’ line. I simply had to remove the <iframe bits. The correct code is below.
Thanks Andreas!

let newsrc = ‘https://www.mywebsite.com=’ + $w(" #userinput ").value’;

Howdy. Can you explain the page(s) and/or element(s) that made this work for you?