Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 393
  • 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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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