PDA

View Full Version : How to open a page in a different frame via a drop-down menu?


Tomas
02-06-2003, 07:56 PM
Hello everyone,

please can someone be helpful with the following?

How to arrange the JS code below so that the pages linked from the form (that's located in a frame) would open in a different frame called "diskog" or in a new window (ie. where to insert an attribute known in HTML as "target" and how to modify it's properties)?
I like this element and I was searching thru various JS sites, but found only information about forms in general or drop-down menus with "go" button; no mention about linking into an existing frame. And unfortunately I can't recall any site that uses this navigation system now.

Any help will be appreciated.

Many thanks in advance.

Tom


<html>
<head>
<script>
function ChangeURL()
{
select=document.getElementById('select1');
if (select.selectedIndex!=0)
document.location=select.options[select.selectedIndex].value;
}
</script>
</head>

<body>
<select id=select1 onchange=ChangeURL()>
<option value=''>(choose a section)</option>
<option value=''></option>
<option value='e_diskog_s.html'>singles</option>
<option value='e_diskog_a.html'>albums</option>
</select></form>
</body>
</html>

ACJavascript
02-06-2003, 08:10 PM
you could accomplish that like so

-----

<script>
function ChangeURL()
{
select=document.getElementById('select1');
if (select.selectedIndex!=0)
parent.diskog.location.href=select.options[select.selectedIndex].value;
}
</script>

-------

I havn't worked with frames in a while but I think thats the coding for it hehehe :D

the parent.diskog is sending the page to that frame..
for a completely new window you could do somthing like this

------
<script>
function ChangeURL()
{
select=document.getElementById('select1');
if (select.selectedIndex!=0)
window.open(select.options[select.selectedIndex].value,"def")
}
</script>
------

Hope this has helped :D
Happy Scripting!

dagaffer
02-06-2003, 08:12 PM
Would this work?


<html>
<head>
<script>
function ChangeURL()
{
select=document.getElementById('select1');
if (select.selectedIndex!=0)
document.frames[diskog].location.href=select.options[select.selectedIndex].value;
}
</script>
</head>

<body>
<select id=select1 onchange=ChangeURL()>
<option value=''>(choose a section)</option>
<option value=''></option>
<option value='e_diskog_s.html'>singles</option>
<option value='e_diskog_a.html'>albums</option>
</select></form>
</body>
</html>

Tomas
02-06-2003, 11:42 PM
Thanks for your help, AC! It works perfectly.
Dagaffer, your code update doesn't work, but never mind!

Many thanks to you both for your willingness.

Tom

ACJavascript
02-08-2003, 12:12 AM
No problem Tom! :D

Happy Scripting :D:D