Results 1 to 9 of 9
Aug 3, 2012, 02:14 #1
Why put input hidden field in display:none style?
In Django framework, I find the hidden forms fields in a div style="display:none"
For example for the security token
<input type="hidden" name="csrfmiddlewaretoken" value="894yb3poe6de233c6b3742685a98472f">
I want to know the reason, because in any case, all fields of type hidden are not visible.
Aug 3, 2012, 23:31 #2
There is no reason.Logic without the fatal effects.
All code snippets are licensed under WTFPL.
Aug 4, 2012, 00:03 #3
The basic reason behind using hidden fields is to pass some value in PHP, which you do not want to be shown in your webpage directly. And the person used style to hide the Div box, to hide it too.. There is no big deal with it.
Many people use Hidden input types to pass a large number of variables according to needs
Aug 4, 2012, 02:13 #4
Okay, so put the hidden DIV box is useless since the field is already hidden type.
Aug 4, 2012, 02:32 #5
- Join Date
- Jul 2006
- Victoria, Australia
- 28 Post(s)
- 1 Thread(s)
Aug 4, 2012, 07:41 #6
Aug 4, 2012, 16:07 #7
- Join Date
- Jun 2008
- Madison, WI
- 31 Post(s)
- 0 Thread(s)
That does seem rather redundant. It is possible, however that i was done so as to be able to put the input there (for some on known reason) while not disturbing the flow of other elements. Still.. oddTips for better/ faster SitePoint forum answers
Brilliant ideas, elegant execution.
Graphic Design, Art Direction, Copywriting and Web Design.
Aug 5, 2012, 03:47 #8
- Join Date
- Aug 2008
- The Netherlands
- 138 Post(s)
- 2 Thread(s)
As discussed here (among others) in older browsers (i.e., legacy IE) hidden input fields took up some space. Wrapping them in a display: none div makes sure they're completely invisible and don't take up any space.
Indeed I'd say that nowadays this is no longer needed as all browsers render hidden inputs correctly now.Rémon - Hosting Advisor
Minimal Bookmarks Tree
My Google Chrome extension: browsing bookmarks made easy
Aug 5, 2012, 14:10 #9
Thank you for your answers.
PS: I just noticed that Django is also the same for its security token, it's weird that they add a box hidden div to keep compatibility with older browsers and it support the HTML5 which is not compatible with the older web browsers.