modified javascript code for cancel button