Jump to content

<option> onClick??


glenelkins

Recommended Posts

Hi

I 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?
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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...
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.