SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2001
    Location
    RI, USA
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem referencing objects with js

    Hi,

    I have 2 objects on my page..
    a 'TD' named 'delete_form_tab' and..
    a 'TABLE' named 'delete_form'

    when a user clicks on this link..
    <A href='void(0)' onclick='show(delete_form);'>

    the following func gets called..

    function show(what) {
    what.style.display = "";
    what+"_tab"+.className = "DataTD";
    }

    this lets me show the hidden 'delete_form' TABLE, but I also want to change the style of the 'delete_form_tab' TD -- and I know I'm doing something wrong with the concanation of the '_tab' part.. for example, this works..

    function show(what) {
    what.style.display = "";
    delete_form_tab.className = "DataTD";
    }

    but, I want to be able to pass the 'delete_form' to the function, and just append the '_tab' to the end of it to have it refer to the TD object.

    does this make sense to anyone?
    in1.com | Bootply - Bootstrap playground

  2. #2
    SitePoint Zealot
    Join Date
    Nov 2001
    Location
    RI, USA
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    fixed my own problem

    I fixed it by passing 'delete' as a string, and changed the function to..

    function show(what) {
    var mytable = eval("form_"+what);
    var mytab = eval("form_"+what+"_tab");
    mytable.style.display = "";
    mytab.className = "DataTD";
    }
    in1.com | Bootply - Bootstrap playground


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
  •