?
Solved

How do I clear a hidden JSP field using javascript?

Posted on 2009-12-29
2
Medium Priority
?
440 Views
Last Modified: 2012-06-21
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.
0
Comment
Question by:ltownbarry
2 Comments
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 26140227
write onblur or onchnge method function and set the value u mention retutn true
then it wont go to server
0
 
LVL 3

Accepted Solution

by:
Nithyanandhan_T earned 1000 total points
ID: 26140393
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question