Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a hidden field in JavaScript

Tags:

javascript

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

    <html>     <head>       <script type="text/javascript">       var a =10; function test() {       if (a ==10)  {         //  ... Here i need to create some hidden field for form named = chells       } }       </script>       </head>        <body >       <form id="chells" name="formsdsd">       <INPUT TYPE=BUTTON OnClick="test();">      </form>      </body>     </html>  
like image 445
joe Avatar asked Jun 16 '09 11:06

joe


People also ask

How do you hide a field in Javascript?

You can use below syntax in client script to hide a field. g_form. setVisible('fieldName', false);

How do you create a hidden field?

Definition and Usage. The <input type="hidden"> defines a hidden input field. A hidden field lets web developers include data that cannot be seen or modified by users when a form is submitted. A hidden field often stores what database record that needs to be updated when the form is submitted.

What is hidden form field?

Hidden form field is used to store session information of a client. In this method, we create a hidden form which passes the control to the servlet whose path is given in the form action area. Using this, the information of the user is stored and passed to the location where we want to send data.


1 Answers

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 . document.getElementById("chells").appendChild(input); 
like image 199
5 revs, 5 users 47% Avatar answered Sep 28 '22 19:09

5 revs, 5 users 47%