0

Hi I have a simple JavaScript question, I haven't used JavaScript for a while, so was wondering if you could help.

<?php
$sizeChartIcon= Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."size-charts/size-icon.gif"; ?>

<a onclick="$('size-chart').show();"><?php echo '<img src="'.$sizeChartIcon.'" alt="size chart">' ; ?></a> 

<div id="size-chart" style="display:none;"> <?php echo  Mage::app() ->getLayout() ->createBlock('cms/block') ->setBlockId($_product->getAttributeText('size_chart_template')) ->toHtml(); ?>
</div>

This shows the static block if you click on the sizeChartIcon, but it stays open, how would I hide it again if the customer was to click on the icon again?

1 Answer 1

1

Call this instead of show()

<script type="text/javascript">
<!--
    function toggle_visibility(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
    }
//-->
</script>

Source: http://blog.movalog.com/a/javascript-toggle-visibility/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.