PDA

View Full Version : combo box which open contents in new window..with each selection a different bgcolor


vkidv
04-14-2003, 10:22 AM
i cant seem to get a script to work, probably because i made it myself:
<script language="JavaScript">
function gothere(){
if (!window.newwindow) {
newwindow=window.open("loading.htm","win1","width=200,height=100") }
}
newwindow.location=thebox.example.options[thebox.example.selectedIndex].value
focus1=newwindow.focus()
</script>

the script is meant to open the value of whatever the selection value in the combo box into new window (it should detect if it is already open or not)
im rather tired and i can seem to notice any mistakes..
also in the combo box

<select name="example" onChange="gothere()">
<option value="ceramics1.htm">ceramanics</option>
<option selected value="loading.htm">--please select an option--</option>
<option value="index.htm">poo</option></select></td>
</tr><tr>
<td width="180" height="61"></form>

also, not as important. but how do i make each selection have a different background colour? like selection ceramanics has a background of blue. and 'poo'* green? i think this can be done with CSS but im not sure.

*dont ask...just quick to type..

Spudhead
04-14-2003, 01:23 PM
What's it doinf as it is? Throwing an error? Refusing to do anything at all?

I'd try changing these lines:

newwindow.location=thebox.example.options[thebox.example.selectedIndex].value
focus1=newwindow.focus()

to:

newwindow.location.href=thebox.example.options[thebox.example.selectedIndex].value;
newwindow.focus();

cheesebagpipe
04-15-2003, 12:32 AM
cant seem to get a script to work, probably because i made it myselfThat's the spirit.

var newwindow = null;

function gothere(oSelect) {
if (newwindow && !newwindow.closed) newwindow.close();
var url = oSelect[oSelect.selectedIndex].value;
newwindow=window.open(url,"newwindow","width=200,height=100");
if (newwindow && !newwindow.closed) newwindow.focus();
}

</script>

<select name="example" onchange="gothere(this)">
<option value="ceramics1.htm">ceramanics</option>
<option selected value="loading.htm">--please select an option--</option>
<option value="index.htm">poo</option></select>

Why not just put the BG color in the HTML file? You could change it with newwindow.document.body.style.background = color;

glenngv
04-15-2003, 08:53 AM
<select name="example" onChange="gothere()">
<option value="ceramics1.htm" style="background-color:blue">ceramanics</option>
<option selected value="loading.htm" style="background-color:red">--please select an option--</option>
<option value="index.htm" style="background-color:green">poo</option>
</select>

take note that not all browsers support background-color in option tags.

vkidv
04-16-2003, 09:36 PM
Thanks for tall the help :)
problem solved :D