• Hi,
    I am trying to add a widget.
    The widgets form should be dynamic.
    for example Email filed is shown just if a checkbox is selected.

    From some reason i cant get it to work.

    Here is the code:

    <input id="checkme" type="checkbox" />
    <div id="extra">
    <label for="email">Email Address:</label>
    <input id="email" type="text" />
    </div>

    and the javascipt:

    <script type="text/javascript"> 
    
    	$(document).ready(function(){
    		//Hide div w/id extra
    	   $("#extra").css("display","none");
    		// Add onclick handler to checkbox w/id checkme
    	   $("#checkme").click(function(){
    		// If checked
    		if ($("#checkme").is(":checked"))
    		{
    			//show the hidden div
    			$("#extra").show("fast");
    		}
    		else
    		{
    			//otherwise, hide it
    			$("#extra").hide("fast");
    		}
    	  });
    
    		});
    	 </script>

  • The topic ‘javascript within widget form’ is closed to new replies.