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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question "object required" error

    Hello. I m trying to create an expand/hide button. It would be an image that, when clicked, would either expand or hide a table and change the img src from arrow-up to arrow-down or vice versa. I'm getting an "object expected" error in the following code:

    <script type="javascript">
    function displ(tblID, that)
    {
    var showhide;
    showhide='';
    if (that.src=="images/blackD.gif"); //click on down, show table
    {
    showhide=='block';
    up(that);
    }
    else
    {
    showhide=='none';
    down(that);
    }

    showhide='block';
    window.document.getElementById(tblID).style.display=showhide;
    return true;
    }

    function up(that)
    {
    imgU = new Image(); imgU.src = "images/blackU.gif";
    that.src=imgU.src;
    }

    function down(that)
    {
    imgD = new Image(); imgD.src = "images/blackD.gif";
    that.src=imgD.src;
    }

    </script>

    <img src="./images/blackU.gif" alt="" width="12" height="10" border="0" onclick="displ('tbl', this);">

    <!--A table with id='tbl'-->

    I get the error on the img line, when I'm calling the function. Anyone know why that is? Thanks in advance,

    Igor.

  • #2
    Regular Coder Vincent Puglia's Avatar
    Join Date
    Jul 2003
    Location
    where the World once stood
    Posts
    367
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Hi Igor,

    1) <script type="text/javascript">
    2) '== ' is for comparison (means 'is equal to')
    '=' is for assignment (means fill left with right)
    3) if (.....);
    means do nothing -- get rid of the semi-colon

    Vinny
    Where the world once stood
    the blades of grass
    cut me still


  •  

    Posting Permissions

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