Cancel button using javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghjk
    Contributor
    • Jan 2008
    • 250

    Cancel button using javascript

    I have "cancel" button in php files. I want to write common javascript function for cancel button. When user click cancel button I want to clear php form data.
    Is it possible?
    Code:
    <input id="Cancel" src="Cancel.jpg" type="image"  alt="cancel"    onclick="Cancel('cancel');"/>
    JS code
    Code:
    function Cancel(cancel){
    	
    	if(cancel=='cancel'){
    		document.getElementById('No').value='';
    		document.getElementById('FullName').value='';
    		document.getElementById('Address').value='';
    		document.getElementById('Email').value='';
    	}
    	
    }
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    Originally posted by ghjk
    Is it possible?
    sure, although I'd go for a simple reset button...

    Comment

    • ghjk
      Contributor
      • Jan 2008
      • 250

      #3
      But my above code is not working. Could you tell me where I goes wrong?

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        are there any error messages in the Console or FireBug?

        Comment

        • ghjk
          Contributor
          • Jan 2008
          • 250

          #5
          No. There are no messages. That's why I'm confusing.

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            then I need a link to see (and test) for myself.

            Comment

            Working...