Questions tagged [hidden-field]

An HTML Input element that users do not see or interact with. It can hold a value and is often used to store client-side variables.

As defined from w3.org:

An INPUT element with `TYPE=HIDDEN' represents a hidden field. The user does not interact with this field; instead, the VALUE attribute specifies the value of the field. The NAME and VALUE attributes are required.

For example:

<input type=hidden name=context value="l2k3j4l2k3j4l2k3j4lk23">

This element is available in the following versions of HTML:

  • HTML 3.2
  • HTML 4.0
  • HTML 5
  • XHTML 1.0

It is important to note that users are able to see the hidden values if they view the source of the page. Hidden fields should never be used to store sensitive information like passwords or credit card information. A good programming guideline is to only use the hidden field to store information that the page has generated or information the user would not know or understand.

913 questions
344
votes
6 answers

jQuery - Create hidden form element on the fly

What is the simplest way to dynamically create a hidden input form field using jQuery?
Mithun Sreedharan
  • 45,549
  • 69
  • 171
  • 232
177
votes
4 answers

rails simple_form - hidden field - create?

How can you have a hidden field with simple form? The following code: = simple_form_for @movie do |f| = f.hidden :title, "some value" = f.button :submit results in this error: undefined method `hidden' for…
153
votes
6 answers

Rails hidden field undefined method 'merge' error

I wanna do something like this in rails Here is what I have so far in rails: <%= form_for @order do |f| %> <%= f.hidden_field :service, "test" %> <%= f.submit %> <% end %> But then I get this error: undefined method `merge' for…
Jake
  • 1,637
  • 2
  • 12
  • 9
103
votes
13 answers

@Html.HiddenFor does not work on Lists in ASP.NET MVC

I'm using a model that contains a List as a property. I'm populating this list with items i grab from SQL Server. I want the List to be hidden in the view and passed to the POST action. Later on i may want to add more items to this List with jQuery…
Anton Smith
  • 1,228
  • 2
  • 10
  • 14
83
votes
2 answers

How do I use hidden_field in a form_for in Ruby on Rails?

I've read this, but I'm new to RoR so I'm having a little trouble understanding it. I'm using a form to create a new request record, and all of the variables that I need to send exist already. Here is the data I need to send (this is in a do…
ben
  • 26,837
  • 40
  • 121
  • 174
48
votes
8 answers

HTML form with multiple hidden control elements of the same name

Is it legal to have an HTML form with more than one "hidden" control element with the same name? I expect to get the values of all of these elements at the server. If it is legal, do the major browsers implement the behavior correctly?
Brian
  • 1,281
  • 2
  • 14
  • 26
48
votes
7 answers

Passing an array into hidden_field ROR

I'm trying to pass an array into a hidden_field. The following User has 3 roles [2,4,5] >> u = User.find_by_login("lesa") => #
JZ.
  • 19,005
  • 31
  • 110
  • 185
44
votes
8 answers

How to read text from hidden element with Selenium WebDriver?

I'm trying to read the example String 1000 out of a hidden
like this: I am aware that WebElement.getText() does not work on hidden elements in Selenium 2 (WebDriver), so I searched for…
dokaspar
  • 6,795
  • 14
  • 59
  • 87
43
votes
5 answers

How to set the value of a input hidden field through JavaScript?

I am trying to call the resetyear function and it's getting called also, but the flow stops at alert("over"). It doesn't transfer its control to resetmaster. String flag = ""; flag = (String) session.getAttribute("flag"); …
Divyang
  • 511
  • 2
  • 8
  • 18
40
votes
10 answers

yii2 hidden input value

In Yii2 I'm trying to construct hidden input echo $form->field($model, 'hidden1')->hiddenInput()->label(false); But I also need it to have some value option, how can I do that ?
David
  • 3,756
  • 12
  • 45
  • 77
38
votes
3 answers

Bind hidden inputs to model in angular

I have following form:
MRB
  • 3,617
  • 3
  • 29
  • 40
35
votes
11 answers

Can't set hidden input field's value using jQuery

I have a simple input field inside a form tag: I tried to set this value from a js file: $(document).ready(function(){ …
framomo86
  • 1,195
  • 2
  • 13
  • 17
34
votes
4 answers

JQuery: Change value of hidden input field

I'm having a hella time setting the value of a hidden input. I want to pass the HTML from between the option tags to the hidden field- end run it will the page title from wordpress' wp_list_dropdowns(). I've got it returning the text just fine,…
helgatheviking
  • 22,590
  • 11
  • 82
  • 134
33
votes
1 answer

Rails - Update a single attribute : link with custom action or form with hidden fields?

Let's say I have a User model, with a facebook_uid field corresponding to the user's facebook id. I want to allow the user to unlink his facebook account. Do do so, I need to set this attribute to nil. I currently see 2 ways of doing this First way…
MrRuru
  • 1,832
  • 2
  • 19
  • 23
32
votes
4 answers

Chrome warning "[DOM] Password forms should have (optionally hidden) username fields for accessibility" in console even with hidden username field

When visiting the "reset password" route of my single-page app and looking at the Chrome browser console, I am greeted with the follwing warning: [DOM] Password forms should have (optionally hidden) username fields for accessibility: (More info:…
arne.b
  • 3,934
  • 2
  • 21
  • 43
1
2 3
60 61