SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast wildekyote's Avatar
    Join Date
    Apr 2003
    Location
    Fredericksburg, VA
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Image swap headache

    I'm currently having an issue with a script thats driving me nuts. I have a checkbox to a form that will select whether the submission is urgent or not. Now I want an image to appear when the check box is selected and 2 fields to be enabled for editing. With the code that I have now everything loads properly. When you select "Urgent" the fields enable and the image appears. When I uncheck "Urgent" the fields disable again but I can't get the image to disappear. any ideas? It is set to an onClick event. I've tried onChange too but no luck.
    Code:
    function enableUrgentTxar()
    { with (document.frmRequest)
      { if (chkUrgent.checked)
        { txarImpact.disabled = false;
          txarJustify.disabled = false;
          txarImpact.style.backgroundColor='white';
          txarJustify.style.backgroundColor='white';
          txarImpact.focus();
          showUPimage = "<img name='usrPriority' src='../GRAPHICS/user_prio.gif' alt='User Priority'>";
          document.all.usrPriority.innerHTML = showUPimage;
        }
        else
        { txarImpact.disabled = true;
          txarJustify.disabled = true;
          txarImpact.style.backgroundColor='#CCCCCC';
          txarJustify.style.backgroundColor='#CCCCCC';
          showUPimage = " ";
          document.all.usrPriority.innerHTML = showUPimage;
        }
      }
    }
    You only regret the risks you didn't take.

    Keith Andersen.com

  2. #2
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Caveat: I've not tested this and I've used document.all as you have whereas document.getElementById would be better.

    Code:
    <html>
      <head>
    	<script language="JavaScript" type="text/javascript">
    	<!--
    	  function enableUrgentTxar()
    	  { with (document.frmRequest)
    		{ if (chkUrgent.checked)
    		  { txarImpact.disabled = false;
    			txarJustify.disabled = false;
    			txarImpact.style.backgroundColor='white';
    			txarJustify.style.backgroundColor='white';
    			txarImpact.focus();
    			document.all.usrPriority.style.display='block';
    		  }
    		  else
    		  { txarImpact.disabled = true;
    			txarJustify.disabled = true;
    			txarImpact.style.backgroundColor='#CCCCCC';
    			txarJustify.style.backgroundColor='#CCCCCC';
    			document.all.usrPriority.style.display='none';
    		  }
    		}
    	  }
    	
    	//-->
    	</script>
    	  
      </head>
      <body>
    	<img id='usrPriority' src='../GRAPHICS/user_prio.gif' alt='User Priority' style="display: none;">
       </body>
    </html>
    Andy
    From the English nation to a US location.

  3. #3
    SitePoint Enthusiast wildekyote's Avatar
    Join Date
    Apr 2003
    Location
    Fredericksburg, VA
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never thought of using a style thanks for the help worked perfectly.
    You only regret the risks you didn't take.

    Keith Andersen.com

  4. #4
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wildekyote
    Never thought of using a style thanks for the help worked perfectly.
    We please to aim

    Quote Originally Posted by wildekyote
    You only regret the risks you didn't take.
    Words to live and die by. Nice tagline!
    From the English nation to a US location.


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
  •