PDA

View Full Version : trying to show a dropdown value rather than my request code


chris_angell
05-16-2003, 02:15 PM
Hi I have a problem,

I am trying to take a value from a drop down box and use this to call a pop up window but it is not taking the value, it is putting the request..

see

function openSNAPS(){
window.alert('"snaps/LGsnaps/ + links.SNAPSdropdown.value + .htm"','snaps','width=350 , height=223','snaps');
}


with the + links.SNAPSdropdown.value + it is alerting this not the dropdown box value ?? what am I doing wrong do ya think.. is it because of the width and height values ???

beetle
05-16-2003, 02:36 PM
no - that's not the proper way to retrieve a value from a SELECT

selectObj.options[selectObj.selectedIndex].value

cheesebagpipe
05-16-2003, 03:39 PM
beetle is right (although Select.value is pretty widely supported by now); but you've got other problems. Is this what you're trying to do?

function openSNAPS() {
window.alert('"snaps/LGsnaps/' + links.SNAPSdropdown.value + '.htm","snaps","width=350,height=223"');
window.open('snaps/LGsnaps/' + links.SNAPSdropdown.value + '.htm','snaps','width=350,height=223');
}

chris_angell
05-16-2003, 04:24 PM
yeah, but I did the alert just to see if the value would come up.

but it is showing


+ links.SNAPSdropdown.value +



hmmm

chris_angell
05-16-2003, 04:32 PM
so to use the diffent code would i put


selectObj.options[links.SNAPSdropdown]value


instead of


+ links.SNAPSdropdown.value +

????????

sorry, I don't normally do it this way #??????????
:rolleyes:

cheesebagpipe
05-16-2003, 04:51 PM
Chris...your problem wasn't with the drop-down (hope you're not using NS4) but with your quotes; the reference to the select needs to be outside the quotes, else it'll be simply literally included, instead of being run as code (getting the selected value). As above, w/beetle's suggestion:

function openSNAPS() {
var v = document.mylinks.SNAPSdropdown[document.mylinks.SNAPSdropdown.selectedIndex].value;
window.open('snaps/LGsnaps/' + v + '.htm','snaps','width=350,height=223');
}

Change your form name to 'mylinks' or something else, there already is a document.links.

chris_angell
05-16-2003, 05:30 PM
brilliant it works well.. thanks cheesebagpipe


:) ps.....nice name


are you scottish with a love of cheese by any chance

cheesebagpipe
05-16-2003, 05:52 PM
hah! I am so busted.....:D

Actually: I just wanted to open a new email account for registering with this board, so...I went to yahoo. Tried getting a webmail acct. at yahoo lately? I started with my usual handle, no go, taken, then went to another, no, another, another...*aargh* Finally typed in 'cheesebag' - just 'cause I've always found it funny (I'm older than 12 but my sense of humor isn't) - and: HAH! (taken). So I started adding to it, either end:

_cheesebag_
**cheesebag**
creamcheesebag
grilledcheesebag
johncheesebag (John Cleese was born John Cheese)
cheesebaglady
cheesebagriculture
cheesebag-o-matic
cheesebagpipe

That last was an accident but hey, too late so...stuck with it. No prob, when I post c**p here, people just figure 'heh, what can you expect from a cheesebagpipe...' :thumbsup: