Dynamic iframe by ID

Hi,

I am trying to set an iframe to dynamically change based on selection from a SharePoint feild. I have followed the instructions HERE and they worked

BUT

They set ALL iframes on the page to the same thing. I have more than one iframe AND I have found the "Multi-line Text" field is also an iframe.

Is there a way to set the iframes using an ID. So if I have this in my HTML element:

<iframe id="TestIframe" src = ""  width = "1250" height = "600" > Browser not compatible. </ iframe>

Can I then set the src by using the ID TestIframe to ensure it is only that iframe that changes?

Hello @NG-Helpdesk,

Yes, you can use ID selector..

So the code from the previous post should be updated like this:

fd.spRendered(function(){
   
   function setiFrameURL () {
      $('#TestIframe').attr('src', fd.field('HyperlinkFieldInternalName').value.url);
   }

//set URL on form load
setiFrameURL();

//set URL on Hyperlink fild change
fd.field('Hyperlink').$on('change',setiFrameURL);

});
1 Like

Hi @mnikitina

As always that works perfectly! Thank you very much, Have a great day.

1 Like