views:

18

answers:

1

Does anyone know how I can update the style attribute of a division using an Ajax request?

For example, I have a division I inline style to display:hidden, and when a user clicks a link it changes the style to display:block

A: 

You don't need to perform an AJAX call to perform the above request. Plain old javascript will do. If you are using jQuery, try:

<div id="details">...</div
<a href="#" id="toggle">[Show]</a>

<script type="text/javascript">
  $("#toggle").click(function () {
    $("#details").show();
  });
</script>

For prototype, try:

<div id="details">...</div
<a href="#" id="toggle">[Show]</a>

<script type="text/javascript">
  Event.observe('toggle', 'click', function(event) {
    $('details').show();
    Event.stop(event);
  });
</script>
Kevin Sylvestre
cool that works nice. not sure why I can't use an Ajax request and page.show... doesn't seem to work
Brian