SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict djh's Avatar
    Join Date
    Apr 2000
    Location
    Long Beach, CA
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    List menu - ondblclick event

    I have the following code:
    Code:
    <form name="form1" method="post" action="">
    <select name="select" size="25" width="500" onDblClick="openWin('getValueFromOptionHere','test','width=500,height=400,scrollbars=no')">
        <option selected>1. Dave</option>
        <option name="test">2. Jo</option>
        <option>3. Me</option>
        <option>4. DS</option>
        <option>6. asdsf</option>
      </select>
    </form>
    Where it says "getValueFromOptionHere", I want to pass the value from the specific double clicked option... any ideas?

  2. #2
    SitePoint Zealot Arkkimaagi's Avatar
    Join Date
    Mar 2002
    Location
    Lappeenranta, Finland
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool

    Code:
    <form name="form1" method="post" action="">
    <select name="select" size="25" onDblClick="openWin(this.options[this.selectedIndex].value,'test','width=500,height=400,scrollbars=no')">
        <option value="value1" selected>1. Dave</option>
        <option value="value2">2. Jo</option>
        <option value="value3">3. Me</option>
        <option value="value4">4. DS</option>
        <option value="value5">6. asdsf</option>
      </select>
    </form>
    Try that.

    Now, you must remember that you can not use select multiple options with this thing. (an option that you could switch normally on)

  3. #3
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this.options[this.selectedIndex].value

    Although this works great, sometimes you might want to just touch this.value.
    I'm not sure about compatibility issues - but i always use that when i'm only getting the value - and go through the index when i want className or something.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  4. #4
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Flawless, I have never encountered any cross-browser compatibility issues by going the long way round, since that is the way you're "supposed" to do it!

    Conversely, from some brief research, it would appear that the .value property of the main SELECT element itself (as you suggest) is supported only by IE4 and up! Sorry!
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  5. #5
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you saying NN doesn't support it @ Marco?

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  6. #6
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    According to DWMX's JS reference, yes, but I have taken its information on trust, and thus have not tested it for myself... Will do in the morning...!

    (Why? Are you sure that it does work in NS4?)
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •