Fitering option with doubleclick event

Posted on 2007-07-25
Last Modified: 2008-01-09
I have manage to filter an select list with jscript like making copy and using regexp for filtering, this is a part for making copy

    this.optionscopy = new Array();
    if (this.selectobj && this.selectobj.options) {
      for (var i=0; i < this.selectobj.options.length; i++) {

        // Create a new Option
        this.optionscopy[i] = new Option();

        // Set the text for the Option
        this.optionscopy[i].text = selectobj.options[i].text;

        // Set the value for the Option.
        // If the value wasn't set in the original select list,
        // then use the text.
        if (selectobj.options[i].value) {
          this.optionscopy[i].value = selectobj.options[i].value;
        } else {
          this.optionscopy[i].value = selectobj.options[i].text;

this is working OK but the problem is that I'm having like ondoubleclick event on every option like:

<option ondblclick="eval(parent.location='test.php?id=5')">

and it is working until I use my filter.When I use filter and when my select component is filtered out ondoubleclick option is gone.
I have tried to add this:

this.optionscopy[i].ondblclick = selectobj.options[i].ondblclick;

but it wouldn't help.Can someone tell me can I carry this doubleclick event to copied object somehow or I must find the other way by using value of copied options?
Question by:cstormer
    LVL 4

    Accepted Solution

    can you try this:

    this.optionscopy[i].ondblclick = function () {
      eval (parent.location='test.php?id=5');

    if you really want to just call the same one the other method is calling instead, do this:

    this.optionscopy[i].ondblclick = function () {
      var otherOptions = selectobj.options[i];
      otherOptions.ondblclick ();  // Should invoke its dblclick method...
    LVL 51

    Expert Comment

    do you probably mean:

    You know that the browsers security model should inhibit that child windows change the parent window?

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
    Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
    Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now