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 5 of 5
  1. #1
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,718
    Thanks
    41
    Thanked 191 Times in 190 Posts

    what is wrong with this?

    First, I am new to javascript... I've been trying to get help on a dynamic menu but no one ever seems to respond... So I will start with the pieces... I do not understand why this chunk of code is not working... All i have is a div and the script is simply supposed to make the div have a new size...
    here is the script...

    Code:
    <script type="text/javascript">
        var stretch = 200;
        function Expand(index) {
            var dname = "menu" + index;
            document.getElementById(dname).style.width = stretch+'px';
        }
    </script>
    here is the styling
    Code:
    <style type="text/css">
        .show{height:20px; width:100px; display:block; background:lightgreen;}
        </style>
    and here is the simple html
    Code:
    <div id="menu1" class="show" onclick="runExpand(1)"></div>
    Last edited by alykins; 06-09-2011 at 08:13 PM.

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #2
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Where is your runExpand function?

    Try using the error console.

  • #3
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,718
    Thanks
    41
    Thanked 191 Times in 190 Posts
    doesnt the onclick event of onclick="runExpand(1)" call the function of Expand(index)

    I built this off of a reference demo I found (it was for a js accordion) and they had a function "function Accordion(index){etc}
    and they had a onclick="runAccordion(1)".... is this the wrong way to do it?
    my understanding was that it would then call the function and in essence "ignore" the "run" part and use the "run" part as a directive as to what to do... this logic is wrong?

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #4
    Regular Coder
    Join Date
    Apr 2010
    Posts
    103
    Thanks
    2
    Thanked 15 Times in 15 Posts
    if you call the function runExpand(), it will look for a function called runExpand, what you want to do is just call the expand() function directly.

    in your reference, i would assume that runAccordian() is a separate function that does something, then itself calls accordian().

  • Users who have thanked ohbigrighthand for this post:

    alykins (06-09-2011)

  • #5
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,718
    Thanks
    41
    Thanked 191 Times in 190 Posts
    that did it thanx for clarifying the "runExpand" "Expand"

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE


  •  

    Posting Permissions

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