#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Location
    Canada
    Posts
    368
    Rep Power
    12

    Passing variable to innerHTML syntax


    Bit frustrated getting my show/hide function to work
    I know where the problem is - after ShowNewsComments( - but cannot seem to solve the syntax:
    function ShowNewsComments(snc, comdiv, butdiv){
    if (snc=="h"){
    alert(comdiv);
    document.getElementById(comdiv).style.display = 'none';
    document.getElementById(butdiv).innerHTML = '<input class="buttoncomment rightstuff" type="submit" onclick="ShowNewsComments(\'s\',\'+comdiv+\',\'+butdiv+\')" value="Comments">';
    }
    if (snc=="s"){
    alert(comdiv);
    document.getElementById(comdiv).style.display = 'block';
    document.getElementById(butdiv).innerHTML = '<input class="buttoncomment rightstuff" type="submit" onclick="ShowNewsComments(\'s\',\'+comdiv+\',\'+butdiv+\')" value="Comments">';
    }
    }

    appreciate the help
    mr_fitz
    __________
    Don't worry, I haven't given up my day job.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Location
    Canada
    Posts
    368
    Rep Power
    12

    nevermind...got it


    Originally Posted by mr_fitz
    Bit frustrated getting my show/hide function to work
    I know where the problem is - after ShowNewsComments( - but cannot seem to solve the syntax:
    function ShowNewsComments(snc, comdiv, butdiv){
    if (snc=="h"){
    alert(comdiv);
    document.getElementById(comdiv).style.display = 'none';
    document.getElementById(butdiv).innerHTML = '<input class="buttoncomment rightstuff" type="submit" onclick="ShowNewsComments(\'s\',\'+comdiv+\',\'+butdiv+\')" value="Comments">';
    }
    if (snc=="s"){
    alert(comdiv);
    document.getElementById(comdiv).style.display = 'block';
    document.getElementById(butdiv).innerHTML = '<input class="buttoncomment rightstuff" type="submit" onclick="ShowNewsComments(\'s\',\'+comdiv+\',\'+butdiv+\')" value="Comments">';
    }
    }

    appreciate the help
    This works:

    document.getElementById(butdiv).innerHTML = "<input class=\"buttoncomment rightstuff\" type=\"submit\" onclick=\"ShowNewsComments('s','"+comdiv+"','"+butdiv+"')\" value=\"Comments\">";
    mr_fitz
    __________
    Don't worry, I haven't given up my day job.

IMN logo majestic logo threadwatch logo seochat tools logo