Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: eval problem

  1. #1
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    eval problem

    Hi

    I need to loop trhrough a dynamic number of select boxes in javascript

    for (i = 1; i <= iCount; i++)
    {
    var anOption = Evalwindow.opener.document.createElement("OPTION");
    eval("window.opener.document.frmAdd.drpClient" + i + ".options.add(anOption)");

    }

    I'm getting the following error: 'Evalwindow' is undefined
    Anyone can help me sort it out?

    Thanks

    Kati

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    avoid eval(). What in fact you wanna do? can u detail your problem?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Quote Originally Posted by katib View Post
    var anOption = Evalwindow.opener.document.createElement("OPTION");

    I'm getting the following error: 'Evalwindow' is undefined
    Anyone can help me sort it out?
    So you forgot to define Evalwindow. In order for that statement to work you need to change the window.open() statement to read:

    Code:
    var Evalwindow = window.open(......
    or better just change the statement to:

    Code:
    var anOption = document.createElement("OPTION");
    provided the current page is the one that opened the popup.



    Also you can change:

    Code:
    eval("window.opener.document.frmAdd.drpClient" + i + ".options.add(anOption)");

    and get rid of the eval() by coding it like this:

    Code:
    window.opener.document.frmAdd["drpClient" + i ].options.add(anOption);
    Last edited by felgall; 10-17-2006 at 12:17 AM.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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