Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

I am write code in JS.  When I hit the Submit Button, the JS code needs to check every hidden field.  If the hidden field has a value, it needs to be set back to Null

Posted on 2008-11-18
4
Medium Priority
?
177 Views
Last Modified: 2013-12-12
I am writing in Javascript.  In my validation code, upon hitting "Submit", I need the code to check every "Hidden" field in the form.  If the hidden field has a value, it must be changed back to "Null"
0
Comment
Question by:LGoogin
  • 2
2 Comments
 
LVL 21

Accepted Solution

by:
silemone earned 2000 total points
ID: 22985995
<script>
var theForm = document.forms[0];
var elem = theForm.elements;
for(var i=0;i<elem.length;i++){
  if(elem[i].type=="hidden" && elem[i].value !=""){      
      elem.value = "";
      }
    }
  }
}
</script>
0
 
LVL 21

Assisted Solution

by:silemone
silemone earned 2000 total points
ID: 22986031
this scripts locates all hidden fields and change their value to empty string "" if they are not already ""...

<script>
var theForm = document.forms[0];
var elem = theForm.elements;
for(var i=0;i<elem.length;i++){
  if(elem[i].type=="hidden" && elem[i].value !=""){      

      //do whatever else with the value you do here...store it in a variable, array,  etc..
      elem.value = "";
      }
    }
  }
}
</script>
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

I came across an unsolved Outlook issue and here is my solution.
In the below post we have mentioned the best hosting type for startups. Also, check out some of the superlative web hosting companies that are proposing affordable web hosting solutions to host your startup website.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Loops Section Overview
Suggested Courses

810 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