iFrames - Open new page where contents depend on what user previously selected?

Posted on 2005-05-16
Last Modified: 2006-11-18

I have a HTML page that presents the user with a few choices of jokes (Adult, Knock Knock, Bar..)

If the user selects 'Adult', a new page opens called 'Jokes.html' - with 'Adult.html' as the iFrames ('iFrame') source. If they select 'Knock Knock' - the same page opens but with 'KnockKnock.html' as the iFrames source, and so on.

Is there a simple way to do this (as I am new to JS)? And one that works across different browsers.

Thanks in advance


Question by:xDamian
    LVL 63

    Expert Comment

    Check this:

    <select name="jokeType" onChange="window.frames.iFrame.location=this.value">
    <option value="about:blank">-select-
    <option value="adult.htm">Adult
    <option value="KnockKnock.html">Knock Knock
    <option value="bar.htm">Bar
    <iframe name="iFrame" width="100%"></iframe>


    Author Comment

    Thanks Zvokno - but the iFrame is in a different page.

    So the user makes a choice on say, Index.html, and, depending on their answer, either 'Adult.html' will appear in the 'iFrame' on 'Jokes.html', or it could be 'Bar.html' in the 'iFrame'.
    LVL 63

    Accepted Solution

    Something like this: http:Q_21426214.html

    Author Comment

    Close - but not quite.

    Index.html will have images that they click. On clicking the image, the page 'Choice.html' will open where 'Index.html' once was. And the source page to the iFrame in 'Choice'html' will be determined by the image they chose at Index.html.

    I tried the example above but could not get it to work
    LVL 63

    Expert Comment

    What's the name of this game? "Guess what my page looks like"??? Hey dude, show you html source here and state on what input action you expect what behaviour. We are wizards here, but guessing your next wish can become boaring...

    Author Comment

    Thanks Z: In the end, the easiest option was to have the new page load into the current iFrame - rather than open up a brand new page and iFrame. So the example you gave above works then.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
    JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now