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
https://forums.phpfreaks.com/topic/27465-onclick/
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
https://forums.phpfreaks.com/topic/27465-onclick/#findComment-125629
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
https://forums.phpfreaks.com/topic/27465-onclick/#findComment-126041
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
https://forums.phpfreaks.com/topic/27465-onclick/#findComment-126060
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.