View Full Version : Help with Javascript + Form Button

06-14-2010, 09:47 PM
Good afternoon.

I'm trying to make it so a 'radio button' in a 'form' will 'collapse' a Div that I have hidden.

I'm using the JavaScript to control the collapse, and google's Jquery for the rest of it.

here's the code.

<script type="text/javascript" src="SpryAssets/collapse.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
animatedcollapse.addDiv('test', 'fade=1, group=test, speed=400')

animatedcollapse.ontoggle=function($, divobj, state) { //fires each time a DIV is expanded/contracted
//$: Access to Jquery
//divobj: DOM reference to DIV being expanded/collapsed. Use "divobj.id" to get the ID.
//state: "block" or "none", depending on the state.


and the body code...

<form action="myform.php" method="post">
<a id="collapsable" href="javascript:animatedcollapse.toggle('test')"> [+]
Testing the Collapsability of this Scripting.</a>
<div id="test" style="display:none;">
<h1> You can see that if you toggle the 'Image Display' Button. This will display Properly.</h1>

You can find a completely working version (When not using Radio buttons and forms) located at My Toggle Works Here. (http://www.olivetreepubs.com/toggleworks.html)

Alternatively, you can find the NON working version, which is what I'm attempting to get to work, located at My Toggle Doesn't Work. (http://www.olivetreepubs.com/toggledoesntwork.html)

you can see that in the version that doesn't work, if you hit the 'Radio button', it will collapse, and immediately uncollapse the Div, I don't get why it does this.

Any help is greatly appreciated.

06-15-2010, 07:22 PM
No one is able to help?