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 ;
}