开发者

What will be the value of an element in a form if it doesnt exist in HTML?

I have a divider with a element from an HTML form... (text element) I change the div css display开发者_StackOverflow to none with javascript what will be the value of the element if the divider is set to display none ??

What will the value be if the element never existed in the first place ?


It will be whatever the 'value' attribute of the form element is. The CSS styling has no affect on the form values sent back to the server.

<form action="post_to_me.php" method="post">
 <input type="text" name="hideme" value="Initial value" style="display:none;" />
 <div style="display:none;">
  <input name="hideme2" type="text" value="Initial value" />
 </div>
 <input type="submit">
</form>

The form will post with both hideme and hidem2 equal to "Initial value"


The value of a form element isn't affected by whether or not it is rendered. It will be the same as what it is when display is not none.


If the containing div element is hidden the value of the input element within it will not change. FYI. If the element is hidden it doesnt mean it doesnt not exist in the dom.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜