PDA

View Full Version : why isn't this simple script working properly?



ahs10
08-02-2007, 10:46 PM
so in the code below, if the user is to select the first option (with a value of "xxx") it still opens a new window. why? i want it to only open a window when the value of whichURL is something other than "xxx". i've tried using null, taking away the value of the first option, changing window.open to call a separate function, and a few other things. how can i get my desired results?

<select name="tempGen" size="1" onChange="generate(this.form.tempGen.options)">
<option value="xxx">•••General•••</option>
<option value="templates/General1.html">General One</option>

function generate(whichURL) {
if(whichURL != "xxx") {
window.open(whichURL[whichURL.selectedIndex].value,'POPPER','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable= no,width=200,height=200');
}
}

thetestingsite
08-03-2007, 12:40 AM
Try this instead:



function generate(whichURL) {
if(whichURL[whichURL.selectedIndex].value != "xxx") {
window.open(whichURL[whichURL.selectedIndex].value,'POPPER','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable= no,width=200,height=200');
}
}


Not sure if it will work or not, but hope this helps nonetheless.

Twey
08-03-2007, 01:07 AM
<select name="tempGen" onchange="generate(this.options[this.selectedIndex]);">
<option value="">•••General•••</option>
<option value="templates/General1.html">General One</option>
function generate(u) {
if(u) open(
u,
'POPPER',
['toolbar=no',
'location=no',
'directories=no',
'status=no',
'menubar=no',
'scrollbars=no',
'resizable= no',
'width=200',
'height=200'
].join(','));
}