Results 1 to 2 of 2

Thread: Use a name of object in String to access that Object

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    Grand Rapids, MI
    Posts
    231

    Unhappy

    I have an array , the 3rd item is the name of an object on a page for example like "3_2|Check" how do I access that checkbox by a name I have in a string, so that I Can enable/disable it. This kind of thing has always fustrated me, no matter what language it is in, the reason its in a string to start with is because I created the JS array through ASP.
    -Karl Blessing aka kb244{fastHACK}
    [email protected]

  2. #2
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243
    Hi,
    If the array is in JavaScript then you can use it's eval function (which, as you quite rightly pointed out, is sadly missed in most other languages.)
    example:
    Code:
    <SCRIPT Language = "JavaScript">
    
    var StrString = "Checkbox1";
    var MyObject = eval("document.all.form." + StrString);
    
    MyObject.checked = true;
    
    </SCRIPT>
    Hope this helps

    Shaun
    Web/Application Developer
    VB6 Ent (SP5), Win 2000,SQL Server 2000

Posting Permissions

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



Click Here to Expand Forum to Full Width