i have drop down menus that when you select an option they automatically go to that link wherever it is [for the sake of the argument lets make it a new window]
now i also have a display window script that i've used before that allows you to change the window size of the new window for each link.
now my problem is when i try to add that to the script for the form it doesn't work. no matter how i've played with it the best i've gotten is for it to open in a new window. is there a way to allow the new window to change size depening on what option is selected in the drop down menu?
edit: here's a link to what i have currently, http://artlist.united.net.kg/selectform.html
as far as i know i can't insert the javascript into the option value and i believe the option value is only supposed to be one, so having three items listed there is confusing it.
that does open at the size i set, however it takes a long time to open the window and the page doesn't end up loading. i'd fix it but the javascript is beyond my understanding.
i tried something simple with the window open
<form name="form1">
<select class="px9black" style="width: 155px" name="menu" onChange="window.open(document.form1.menu.options[document.form1.menu.selectedIndex].value,'width='510',height='500',resizable=0,scrollbars=no,menubar=no');">
<option selected>art / photo</option>
<option value="art.html">art</option>
</select>
</form>
that when i take out the width and height it opens in a new window, but if i treat it like a simple window.open script and add the variables it won't work.
cruel_love
11-19-2003, 11:09 AM
EDIT: i managed to simplify that top javascript to this:
<SCRIPT LANGUAGE='JAVASCRIPT' TYPE='TEXT/JAVASCRIPT'>
<!--
var popupWindow=null;
function popup(mypage,myname,w,h){
settings='width='+ w + ',height='+ h + ',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';popupWindow =window.open('',myname,settings);
}
// -->
</script>
which works great but it still is giving me a blank page it won't load the actual page i want it to. [yes the page does exist i have it open right next to what i'm currently working with]
migwich
11-19-2003, 12:35 PM
Hey Cruel_love,
Great job! It looks like the only thing you missed was URL declaration.
window.open('',myname,settings);
should be...
window.open(mypage,myname,settings);
cruel_love
11-19-2003, 02:33 PM
ok i fixed that, but the url still won't load.
here are the links to two different scripts that i've gotten to open pre-sized:
and the page i'm using to load in the new window:
http://artlist.united.net.kg/art.html
now the code i got was from htmlbasix and the only option it had for forms was a form button and the script works fine as that. [http://artlist.united.net.kg/selectform3.html]
but when i try to change it to work in a drop down menu, that's when i'm running into my problems. everything seems fine the only stuff i'm taking away is the extra x,y top, left positioning elements in the script, so why isn't it working?
even if i change onClick to onChange, it isn't working.
one last question then i'll stop bothering you. if the option value is what loads a page, by selecting it, shouldn't it act like a normal <a href="yadayadayada"> tag? like this:
It's no bother, really, you might be able to help with some of my JS issues later :">
To be honest, I never tried the method you've listed. I suspect that it wouldn't work because the "value" is a static string and won't parse HTML code (also you'd need a way to escape the "quotes" within the anchor tag).
You need an event handler like "onchange" to listen for your actions. Once the action takes place, the cooresponding function/script is called.
onchange affects: select menu & text input elements.
onclick affects: links & buttons.
I hope this answers your question. If not, just ask again.
--
P.S. I apologize for the code sample I listed above (4th post from top). It's missing a comma after the window name and will only open a new window with dynamic sizing once.
migwich
11-19-2003, 10:24 PM
On a side note:
This code should do the same thing but allow you to declare separate Window Sizes for each new window.
ar= myindex.split(','); // Dissect the value string
$URL= ar[0];
$W= ar[1];
$H= ar[2];
if (ar[0]!= "0"){
if ($win== null || $win.closed){
$win= window.open($URL,"displayWindow",'width='+ $W +',height='+ $H +',resizable=0 scrollbars=no,menubar=no');
}else{
$win.location.href= $URL;
$win.resizeTo($W,$H); // WARNING: ResizeTo will cause an Access Error if the targeted page is not on your server.
$win.focus();
}
}
}
</script>
<head>