How do I clear a hidden JSP field using javascript?

I want the user to be able to click on a hyper link that will clear the value in a hidden field.  
here i sm code
<TD  ><INPUT type="hidden" name="myField" value="initial value that i want to clear">
<LABEL id="myField" style="font-weight: lighter"></LABEL>
</TD>

The javascript that I call currently does
document.myForm.myField.value="";  

When I submit the form, the field will come back blank but I want it to clear without having to go back to the server.
ltownbarryAsked:
Who is Participating?
 
Nithyanandhan_TCommented:
Few solutions

1) Disabled values will not be posted to server.

formName.formElement.disabled = true;

2) Place all the hidden elements in a <div id="wantToClear">

before submitting the form do the below operation,
document.getElementById("wantToClear").innerHTML = ""; //Watch for proper syntax

3) You can remove the form element like this..

    var elm = document.forms[0].elements[name];
    elm.parentNode.removeChild(elm);


Hope that helps!!
0
 
Sathish David Kumar NArchitectCommented:
write onblur or onchnge method function and set the value u mention retutn true
then it wont go to server
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.