joe joe - 4 years ago 121
Javascript Question

Create a hidden field in JavaScript

How do you create a hidden field in JavaScript into a particular form ?

<script type="text/javascript">
var a =10;
function test() {
if (a ==10) {
// ... Here i need to create some hidden field for form named = chells
<body >
<form id="chells" name="formsdsd">
<INPUT TYPE=BUTTON OnClick="test();">

Answer Source
var input = document.createElement("input");

input.setAttribute("type", "hidden");

input.setAttribute("name", "name_you_want");

input.setAttribute("value", "value_you_want");

//append to form element that you want .
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download