FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

How to display different pages in target frames dynamicaly

 


bukaida
I have two dropdown boxes where clicking each element calls different pages.Each page contain a pdf fileand is diplayed on the upper and lower portion of a page frame respectively.Is it possible to design a mother page with two frames where the content of the frame is selected based on the choice of the dropdown box? The mother page should be divided into two page frame and each frame should contain a page coming dynamicaly from drop down selection.Please help urgently.
Gushe
Yup that is managable Smile
But I think you'll need a little part of the site which isn't framed; otherwise the dropdown box will disappear when you take another frame Razz

Or if you just ment your mother page, with on 1 side a frame that changes; you only have to make 1 Iframe Smile
And change the source of the frame when another option is chosen in the dropdown box Smile



~Gushe
Gushe
Here;
Since I like making JavaScripts, I made a script for you that will change the source of a specific Iframe:

The Javascript that you should place in the <head> </head> tags:

Code:
<script type="text/javascript">
function ChangeFrame()
{
document.getElementById("frame1").src=document.getElementById("menu").value
}
</script>



The Iframe:
(This is just example; The only important thing is ID here; so you can make another Iframe and put in anywhere on your site; as long as its ID is right Wink)

Code:
<iframe src="Starting Frame" id="frame1"></iframe>




The Checkbox:
Code:
<form>
<select id="menu" onchange="ChangeFrame()">
  <option>Choose File</option>
  <option value="Link to file 1">File 1</option>
  <option value="Link to file 2">File 2</option>
  <option value="Link to file 3">File 3</option>
</select>
</form>


I'll see If I can replace the Iframe with a Frameset; would be alot easier to make it the right size Smile


Hope this helps,
~Gushe
bukaida
Thanks Gushe, but the appearence is a bit odd with iframe.Cann't it be implemented with frameset?
Thanx in advance.
Gushe
Sure it goes, If I understand you well.. Smile

I'll use a horizontal frameset that will divide your screen in 2.
The mother page will be the upper frame and the frame that changes the lower frame. Smile
[for other frameset options, just change the rows="50%,50%" tags in the frameset. You can see how you like it. Wink for vertical frameset change the rows into cols.]
of course, you still have to add the right sources to the frames in the frameset Wink

The Frameset:
Code:

<frameset id="myFrameset" rows="50%,50%">
  <frame id="upFrame" src="frame_src.htm">
  <frame id="downFrame" src="frame_a.htm">
</frameset>


The Javascript:
Code:

<script type="text/javascript">
function ChangeFrame()
{
document.getElementById("downFrame").src=document.getElementById("menu").value
}
</script>


The Checkbox:
Code:

<form>
<select id="menu" onchange="ChangeFrame()">
  <option>Choose File</option>
  <option value="Link to file 1">File 1</option>
  <option value="Link to file 2">File 2</option>
  <option value="Link to file 3">File 3</option>
</select>
</form>


Hope this is right.
Or do you still mean something else? Smile

Greetz,
~Gushe
bukaida
Thanks Gushe, a bit change is required--

On clicking the menu (say year 2007) an HTML page should be opened(This is already done with your help).Now that page contains the hyperlink (with month Jan, feb,March etc) which when clicked should open the mother page with two frames holding two different pdf files (say file1.pdf in upper and file2.pdf in lower frame when clicked on Jan, file3.pdf in upper and file4.pdf in lower frame when clicked on Feb and so on).Is it possible with your javascipt magic? The link is single, two different files should be opened each time with single click, in one mother page with two frames.Please please help.

PS: EMBED tag is not working with IE6.
Gushe
Well, changing 2 frames with 1 click isn't really a problem; But If you will change the 2 frames.. where will the menu be? Smile Or will there a menu in each page..? because I don't really understand it.. Razz
bukaida
@Gushe: There is a home page with the menu having different years as their element.This is the first page that is to be opened. After clicking any one of the year in the menu the user will be directed to a html page having months as the hyperlink.This page will contain only 12 hyperlinks(one for each month).
Clicking any one of these hyperlink the mother page will be opened with two different files, one at it's upper and one at it's lower frame.Whatever link he may click, the same mother page should be used to display different files(two at a time).

index page(with menu)----->page with 12 hyperlink----->common mother page with two frame.

ONLY THE HOME PAGE WILL HAVE THE MENU.

Please help.
Gushe
If I understand you well; you always have to click the "Back" button go go to the menu again? Smile

but it is no problem going to a new page holding 2 frames with content on each frame Smile


~Gushe
bukaida
@Gushe: you have understood 100% Very Happy .I am a beginner.Waiting for your help.Please help.
Gushe
You Could just make a new page for each link. Razz Smile
Like For each of the 12 hyperlinks you make a page divided in 2 where you display the 2 pages Razz
I though I had a solution but that would always display the same Razz
for my solution you would still need 12 diferent frames.. and than just HTML would be easier Razz


~Gushe
bukaida
So back to square again Sad .The main objective was to use one target page with two frames for all the 12 links.Can it be done if the hyperlinks are substituted by menu(dropdown)? Please help.
Gushe
Well;
You can make the page wih the 12 pages; and above that page you make 2 Iframes, which only hold an invicible pixel (so that you can see the links)
then we can do so that if you click the link the content appears in the 2 Iframes Smile
and then we need somewhere a little place without Iframe to make a "Go Back To Link Page" link Smile

Or

You can divide your screen in 3 frames with frameset, 1 very small on which will just hold the 12 links; and than 2 bigger ones with the content. Smile

I can't come up with any more ideas atm.. Sorry..


~Gushe
bukaida
The second solution is ok for me.Can you please give the sample code? Thanks in advance.

Main page(with menu)->Page with 3 frames,bottom one holding 12 links.

But the thing is two files on the top two frames should be opened by single click at the link.
Please help.
Gushe
Ok Wink
I'll make code asap Smile
The 1 click 2 page thing isn't a problem.
You just have to fill in all the right links Smile (page file sources)

~Gushe
bukaida
Thanks.Egerly waiting for your code.Please solve the backbutton problem also if your time permits.THANKS.
bukaida
is it possible to display pdf file directly in a frame without embedding them in html?please help.
Gushe
Yup; Normally it is. Smile

Ok; Progress so far:
I managed to make 3 frames using frameset;

1. Holds a centered drop down menu.
2 & 3 Hold the content you want.

I managed to do it so that when you change the menu in the header, the content of 1 of the frames changes; But I didn't manage yet to change them both:
I can only add 1 value to an option; So the page doesn't know where to get the second.
So that way, It would be Impossible;

BUT;
I just though of something Smile
If I giva variable name as a value to the options.
Then with a switch statement; I can do so if the value is something; it will change change A to content 1 and frame B to content B.. Smile
You might not totally understand what I mean; but once it's finished it will be clear.
This will be a slightly longer JS; But I think I can do it Smile

I just need something from you;
Can you give me all the (uploaded) links to the files, and the name of the 12 drop down options? Smile
That would spare you a lot of time; and it might be difficult to find where you have to add what Razz

I'll already make the script, ready to be filled in with the links. Smile


Though.. I'm not sure if it will work with all the different frames.
Because it has to get info in alot of different frames.. Confused


Greetz,
~Gushe
adeydas
Its probably me but why not use PHP to do the job?!?
Gushe
1. I can't do php..
2. I like a "challenge", now most of you advanced programmers will laugh at me and make fun of me, but I"m only a beginner. Smile

Well.. that are my reasons Razz

~Gushe
bukaida
The content has to be delivered as standalone application, so PHP is not an option.
@Gushe: In the mean time I have compromised some requirement and made each individual page with two frames to display the contents.After getting your code I will make the change.
In the mean time another major problem arised.The code given by you for opening a html page from the menu(after clicking the menu item) works perfectly for the first time.But if I go back(by back button) and click it again, nothing happens.If I click on another item and go to another page and come back then only that link becomes active again for one more time.Then again it becomes deactivated after coming back.Cannot get around this problem.The code given by you are given below--

Code:

<script type="text/javascript">
function go1()
{
window.location=document.getElementById("menu1").value
}

function go2()
{
window.location=document.getElementById("menu2").value
}
function go3()
{
window.location=document.getElementById("menu3").value
}
function go4()
{
window.location=document.getElementById("menu4").value
}
</script>

</head>

<body bgcolor="#A5BDD8">
<h1 align="center">Welcome to the Meeting section(ONLY 2007 UNDER EXECUTIVE COMMITTEE HAS DATA,however other links are also active)</h1>
<h3><font color="#FF0000">Please Enable the activeX control if prompted by browser.</font></h3>
<hr>

<pre>
<table>
<tr>
<td>
<h5>Governing Body</h5>
</td>
<form>
<td><select id="menu1" onchange="go1()">
<option>Select Year</option>
<option value="display/gov_26jan.html">2007</option>
<option value="display/und_const.html">2006</option>
<option value="display/und_const.html">2005</option>
<option value="display/und_const.html">2004</option>
<option value="display/und_const.html">2003</option>
<option value="display/und_const.html">2002</option>
<option value="display/und_const.html">2001</option>
<option value="display/und_const.html">2000</option>
<option value="display/und_const.html">1999</option>
<option value="display/und_const.html">1998</option>
<option value="display/und_const.html">1997</option>
<option value="display/und_const.html">1996</option>
<option value="display/und_const.html">1995</option>
<option value="display/und_const.html">1994</option>
<option value="display/und_const.html">1993</option>
<option value="display/und_const.html">1992</option>
<option value="display/und_const.html">1991</option>
<option value="display/und_const.html">1990</option>
<option value="display/und_const.html">1989</option>
<option value="display/und_const.html">1988</option>
</select></td>
</tr>
<tr><td colspan="2"><hr></td></tr>
<tr>
<td><h5>Executive Committee</h5></td>
<td><select id="menu2" onchange="go2()">
<option>Select Year</option>
<option value="display/executive/2007/ex_2007_list.html">2007</option>
<option value="display/und_const.html">2006</option>
<option value="display/und_const.html">2005</option>
<option value="display/und_const.html">2004</option>
<option value="display/und_const.html">2003</option>
<option value="display/und_const.html">2002</option>
<option value="display/und_const.html">2001</option>
<option value="display/und_const.html">2000</option>
<option value="display/und_const.html">1999</option>
<option value="display/und_const.html">1998</option>
<option value="display/und_const.html">1997</option>
<option value="display/und_const.html">1996</option>
<option value="display/und_const.html">1995</option>
<option value="display/und_const.html">1994</option>
<option value="display/und_const.html">1993</option>
<option value="display/und_const.html">1992</option>
<option value="display/und_const.html">1991</option>
<option value="display/und_const.html">1990</option>
<option value="display/und_const.html">1989</option>
<option value="display/und_const.html">1988</option>
</select></td>
</tr>
something like this------------

Please help as soon as possible.
PS--I have got another code for the same, which is also not working at all.Can have a look.

Code:

<html>
<head>
<script type="text/javascript">
function urlopen(target)
  {
  window.open(target)
  }
</script>
</head>
<body>

<p ALIGN=Center>
     <center>
          <h1>Example of Form with a Combo Box Hyperlinked using JS</h1>
     </center>
</p>
<form>
     <p>Choose?
          <select NAME="Choose">
               <option VALUE="ABC" onclick="urlopen('http://www.google.com')">Google</option>
               <option VALUE="DEF" onclick="urlopen('http://www.yahoo.com')">Yahoo</option>
               <option VALUE="WHATEVER" onclick="urlopen('pagename.html')">FILE</option>
          </select>
     </p>
</form>

</body>
</html>
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.