Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6816543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:56:19+00:00 2026-05-26T20:56:19+00:00

I have a user selected pdf statement to display in a frame in the

  • 0

I have a user selected pdf statement to display in a frame in the same web page. First I want the list of pdfs that are clickable to appear and then the pdf file to be loaded info frame when the user selects on the same page retaining the rest of the web page.

I am storing what the user has clicked using a global variable(userSelection) in the .js file (see function getUserSelection()). Accessing the same variable in setSource(). This is called while loading the iframe.

Right now, on firefox the function setSource() never gets called and the page doesn’t seem to respond to the mouse click. What am i doing wrong? This functionality is pretty basic, so there must be some work around. Please help!! –jody

    //Javascript
    var userSelection;

    function getUserSelection(yearandDoc)
    {
          userSelection="0";
          switch (yearAndDoc)
          {
       case '0506BS':  userSelection="1";
                             break;
             case '0506RP':  userSelection="2";
                             break;
             default:        break;
          }
    }

    function setSource ()
    {
         switch (userSelection){
            case "1":   document.getElementById("stmtFrame").src = "2005-06_BS_IE_Stmt.pdf";
                  userSelection="0";
                  break;
            case "2":   document.getElementById("stmtFrame").src = "2005-06_RP.pdf";
                  userSelection="0";
                  break;
            default:  document.getElementById("stmtFrame").src = "";
                  break;
      }
    }   


<!-- Here is the HTML -->

 <div>
     <p>2005/06 :  <a href="javascript:getUserSelection('0506BS')">Balance Sheet</a> ||
                   <a href="javascript:getUserSelection('0506RP')">Receipts &amp; Payments</a></p>

     <iframe id="stmtFrame" onload="javascript:setSource()"  frameborder="0" width="100%" height="700" </iframe> 
  </div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:56:19+00:00Added an answer on May 26, 2026 at 8:56 pm

    Firstly, there are a few mistakes:

    function getUserSelection(yearAndDoc) // not yearandDoc
    <iframe ... ></iframe> // before you were missing >
    

    Secondly, I think that changing the src attribute of the iframe calls the onload event. This means that your code is an infinite loop, since the onload event fires a function that adjusts the src attribute.

    If I understand what you’re trying to do, you should be able to just merge the two functions, so that the src attribute only gets changed when you click one of the links:

    function getUserSelection(yearAndDoc)
    {
          switch (yearAndDoc)
          {
             case '0506BS':  document.getElementById("stmtFrame").src = "2005-06_BS_IE_Stmt.pdf";
                             break;
             case '0506RP':  document.getElementById("stmtFrame").src = "2005-06_RP.pdf";
                             break;
             default:        break;
          }
    }
    
    HTML:
    
    <div>
         <p>2005/06 :  <a href="#" onclick="getUserSelection('0506BS')">Balance Sheet</a> ||
                       <a href="#" onclick="getUserSelection('0506RP')">Receipts &amp; Payments</a></p>
    
         <iframe id="stmtFrame" frameborder="0" width="100%" height="700"></iframe> 
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user that want to be able to select a textbox and
This is the scenario i have: im developing a web app that will list
I have a task that I perform in parallel; for instance printing user selected
I have user control on a ASP.NET web page, which contains a GridView and
Background I have a payment page where the user can select from a list
i have user control, which i render on several views. i want to show
First, the desired result I have User and Item models. I'd like to build
How to know what language user have selected to install setup in innosetup ?
I have a code that will prompt user to send a message by selecting
I have a file upload control on my page. When a user selects a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.