SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Scriptalicious & JS DOM Issue

    Hi

    I'm trying to check if a checkbox is checked and if it is show a panel.

    This works however if you click the tickbox again and it still shows but I'm unsure why the code below doesn't work?

    Any tips?

    Code JavaScript:
    function checkrighttowork() {
     
    							if (document.getElementById('righttowork').checked=true) {
    								 $("decextras").show();
    							} else if (document.getElementById('righttowork').checked=false) {
    								 $("decextras").hide();
    							} 
    						}

  2. #2
    SitePoint Wizard
    Join Date
    Jul 2004
    Location
    Minneapolis, MN
    Posts
    1,924
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I haven't tested to ensure this works as you expected, but, at a first glance, you are using "=" (assignment operator) instead of "==" (comparison operator).


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •