SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    Not Bad, eh? Justin Sampson's Avatar
    Join Date
    Aug 2000
    Location
    N.S., Canada
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple Javascript Problem

    Hello,
    Before we start, I know almost nothing about javascript so I'm probably just making a simple error.

    When I run either the mySuspend or myResume function onClick it works fine, but I need to be able to check to see what the stause is and do the opossite (if suspended, resume, if resumed, suspend). But when I run the check function on click nothing happens, what am I doing wrong?

    I made with with almost pure experience from other languages, so it's probably somthing dumb.

    Code:
    <SCRIPT LANGUAGE=\"JavaScript\"><!--
    var Suspended
    	Suspended = 'No';
    function check() {
    
    if (Suspended = 'Yes')
    	{
    	Suspended = 'No';
    		myResume()
    	}
    		else
    	{
    	Suspended = 'Yes';
    		mySuspend()
    
    	}
    
    }
    
    
    function mySuspend() {
    
        document.form.hoursperday.disabled=true;
    	
    }
    
    function myResume() {
    
        document.form.hoursperday.disabled=false;
    
    }
    //--></SCRIPT>

  2. #2
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    if (Suspended == 'Yes') {
    comparison needs a double "equals signs" (==)
    ----Adopt-a-Sig----
    Your message here!

  3. #3
    Not Bad, eh? Justin Sampson's Avatar
    Join Date
    Aug 2000
    Location
    N.S., Canada
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahh.. Thanks. Now somthing else, when I click it the first time, it suspends it (like it should), but when I click it again it still stays suspended, instead of resuming?

    The button code:

    <input type="checkbox" name="unlimited" onClick="check()">

    Anyone know what's wrong?


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
  •