You are viewing limited content. For full access, please sign in.

Question

Question

Use JavaScript to populate iFrames

asked on February 5, 2018

Hi all.

I have a small JavaScript problem.

We are using JavaScript to populate iFrames on a form.

My process is a meeting scheduler for one of our clients.

While planning their meeting they are able to upload a pdf to one of the 15 possible agenda points.

During their meeting, they must be able to see the respective upload to the respective agenda point.

What's happening currently is: I upload a PDF to agenda point number 2, and number 6. Then, on the form they use during the meeting, the iFrames simply appended. I now have what I submitted under number 2 on number 1. Same for what I submitted at number 6 - it's displaying under number 2.

What do I have to do the code I am using to fix this?

Thanks in advance.

0 0

Replies

replied on February 7, 2018 Show version history

I would use a single IFRAME, and then change it's source depending on which button has been clicked. If a particular button agenda step has nothing associated with it, you can just .hide() the iframe until it's needed again.

//this is just a rough sketch. YMMV
$("#button-1").click(function() {
    if(/*some code to figure out if there is a link for this button*/) {
        $("#iframe").attr('src', url);
        $("#iframe").show();
    } else {
        $("#iframe").hide();
    }
});

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.