Skip navigation
super waffle
Currently Being Moderated

How do i duplicate this javascript code with two different messurments?

Aug 17, 2012 8:36 AM

This javascript code was written for a drop down menu, but i cannot figgure out how to duplicate it so i can have a 2nd drop down with different messurments. please help?

 

            function enlarge(id)

            {document.getElementById(id).style.height = '220px';}

            function shrink(id)

            {document.getElementById(id).style.height = '130px';}

            function toggle(id)

            {if(document.getElementById(id).style.height == "130px")

            {document.getElementById(id).style.height = "220px";}

            else{document.getElementById(id).style.height = "130px";}}

 

the code works fine, but i need to have an almost identicle block of code only with different messurements. because the 2nd drop down menu is smaller.

 
Replies
  • Currently Being Moderated
    Aug 17, 2012 9:00 AM   in reply to super waffle

    function enlarge(id,newheight,oldheight)

                {document.getElementById(id).style.height = newheight;}

                function shrink(id)

                {document.getElementById(id).style.height = oldheight;}

                function toggle(id)

                {if(document.getElementById(id).style.height == oldheight)

                {document.getElementById(id).style.height = newheight;}

                else{document.getElementById(id).style.height = oldheight;}}

     

    Then make each call also include the newheight and the oldheight values, e.g.,

     

    <a href="javascript:enlarge('foo','220','130')">menu option</a>

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points