• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 398
  • Last Modified:

javascript, how to read value from hidden field

Suppose i have two forms (A and no name).  In javascript, how do I get to the hidden field value in formA and formwith no name.

<form name="formA" action="dosomething" method="post">
  <input type="hidden" name="fieldA" value="AAAA">
  <input type="submit" value="Submit" />
</form>
<form action="dosomething" method="post">
  <input type="hidden" name="fieldB" value="BBBB">
  <input type="submit" value="Submit" />
</form>
0
rgbcof
Asked:
rgbcof
  • 2
2 Solutions
 
jafrazeeCommented:
document.getElementById("myhiddenfield")
0
 
Sudaraka WijesingheWeb Application ProgrammerCommented:

var fieldA_value=document.getElementsByName('fieldA')[0].value;;
var fieldB_value=document.getElementsByName('fieldB')[0].value;;

Open in new window

0
 
rgbcofAuthor Commented:
Both solutions works.  Thanks for the specifics Sud.
0
 
Sudaraka WijesingheWeb Application ProgrammerCommented:
Glad to help. Thanks for the points.
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now