glenelkins Posted November 16, 2006 Share Posted November 16, 2006 HiI have an select field as follows:[code]<select name='payment'> <option value='neteller'>Neteller</option> <option value='wire'>Bank Draft/Wire</option> <option value='cheque'>Cheque/Check</option></select>[/code]I want to open a different popup for each selection when made. But if i use this code it does not work[code]<option value='neteller' onclick="window.open('url','title','opts')"><option value='wire' onclick="window.open('url','title','opts')">[/code]Ideas? Quote Link to comment Share on other sites More sharing options...
ArcticWolf Posted November 16, 2006 Share Posted November 16, 2006 Heres my first go at trying to help someone but here : -[code]<html> <head> <title> Select Example </title> </head> <body> <select name = "sites" onChange = "javascript:window.open('' + sites.options[sites.selectedIndex].url + '');"> <option url = "http://www.google.com">Google</option> <option url = "http://www.phpfreaks.com">PHP Freaks</option> </select> </body><html>[/code]Basically it gets whatever you put in the options "url" and opens the window.I have changed the names and options around so you can see it working, but I think you can change it back.Let me know if this helps :)ArcticWolf Quote Link to comment Share on other sites More sharing options...
fenway Posted November 16, 2006 Share Posted November 16, 2006 I'm pretty sure FF will choke on that, and it won't validate (for anyone who cares)... you would have to use a lookup hash stored elsewhere in JS and handle this from the onchange event handler of the SELECT tag. Quote Link to comment Share on other sites More sharing options...
ArcticWolf Posted November 17, 2006 Share Posted November 17, 2006 true...and theres the obvious point that if you try to click on the already selected item in the select, it hasnt changed and so it wont display the new window. You would have to change to another item and change back, creating a new window. Ill see what else I can do... Quote Link to comment Share on other sites More sharing options...
Telemachus Posted November 17, 2006 Share Posted November 17, 2006 Usually with select menus I've seen that use onchange, the option you set to selected is just a description, at the very least that makes life easier. IMHO once you've made the basics workable, any extra effort would be better spent on an "Open in new window" checkbox that just changes the location of the current document if it's unchecked, unless for some reason it's absolutely critical to have both windows open at the same time. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.