Web Analytics Made Easy -
StatCounter Internet explorer not allowing me to add options to a select box in a parent window - CodingForum

Announcement

Collapse
No announcement yet.

Internet explorer not allowing me to add options to a select box in a parent window

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Internet explorer not allowing me to add options to a select box in a parent window

    Does anyone know about a bug in IE 5+ (have tried 5.5 + 6.0) which does not allow javascript to add an option to a select box in the parent window? I have Netscape working just fine but cannot get IE to work the same way. The same code works for a select box on the same page but when I go to use the code to the opener, it does not work. Anyone have a workaround?

    Thanks in advance

    Sean

  • #2
    I'm not aware of such issue; it is more likely there might be a mistake or so in the script, you'd post the code, especially considering it's not clear what you may mean by "parent window": a pop up and the parent is the opener? A frameset (parent)?
    IE5 has one of the most powerful engines around so I'd exclude it can't let you refer a select type from a pop up or a frame both. Post the code if you want

    ciao
    Alberto http://www.unitedscripters.com/

    Comment


    • #3
      Are they one the same domain?

      If not, you'll run into cross-domain scripting errors, though Netscape should through the same kind of errors if it is that kind of issue.

      Post some code.
      jasonkarldavis.com

      Comment


      • #4
        wow! thanks for the great response. I have embedded bothe scripts in the body of this message. The first script sets up a form and spawns the second script.

        Thank you all very much for your help.

        Sean

        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

        <html>
        <head>
        <title>Untitled</title>
        </head>
        <script language="javascript">
        function startNew (scriptName,w,h,winName) {
        var newWin = window.open(scriptName,winName,"status=no,width="+w+",height="+h);
        if (newWin.opener == null) newWin.opener = self;
        //top.opener.window.location.href="whatevr";
        }
        function doIt() {
        startNew("tmp_test2.cfm",400,400,"new");
        }
        function doIt2(){
        var d = new Option("Test 3",3);
        document.forms[0].frmTest2.options[2] = d;
        }
        </script>
        <body>

        Testing....


        <cfform action="" method="">
        <select name="frmTest2">
        <option value="1">Test 1
        <option value="2">Test 2
        </select>
        <cfinput type="text" name="frmTest">

        <input type="button" name="" value="Open" onClick="doIt();">
        <input type="button" name="" value="Try Locally" onClick="doIt2();">
        </cfform>


        </body>
        </html>




        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

        <html>
        <head>
        <title>Untitled</title>
        </head>
        <script language="javascript">
        function hitIt() {
        window.opener.document.forms[0].frmTest.value = "hello";
        }


        function hitIt2() {
        var d = new Option("Test 3",3);
        alert(window.opener.document.forms[0].frmTest2.options[window.opener.document.forms[0].frmTest2.selectedIndex].value);
        alert("ok then trying to change");
        window.opener.document.forms[0].frmTest2.options[2] = d;

        }
        </script>
        <body>
        Ok we are getting here

        <cfform action="" method="">
        <input type="button" name="" value="Hit it" onClick="hitIt();"><br><br>
        <input type="button" value="Second" onClick="hitIt2();">
        </cfform>


        </body>
        </html>

        Comment


        • #5
          Now this is interesting - a quick glance over the code reveals nothing glaringly wrong.

          And it does work in NS4, which typically is the browser that has issues.

          And from my own verification, it works in Mozilla 1.1 Alpha (just had to remove cf in front of certain tagnames, bah, ColdFusion ).

          And does not work in IE6.... (which you already knew ).

          Just a few checks, window.opener DOES point to the proper window, and window.opener.document.forms[0].frmTest2 refers to the select element properly.

          I am really puzzled by this, maybe somebody else has an idea?
          jasonkarldavis.com

          Comment


          • #6
            It's not your code. It's microsoft. Apparently they've disabled cross-window form option updating. Supposedly a security thing. *shrug* One way to get around this is to have the function that adds the option on the same page as the select list. You can call the function from the daughter window though.

            change your doIt2 function to something like this.

            function doIt2(optText, optValue){
            var d = new Option(optText,optValue);
            document.forms[0].frmTest2.options[2] = d;
            }

            in tmp_test2.cfm

            function hitIt2() {
            window.opener.doIt2("Test 3", "3");
            }

            Comment


            • #7
              Thanks!

              Sean

              Comment

              Working...
              X