[英]Can someone please explain what this means exactly?
I found this line of code in a script function and I have no idea what it means or how to alter it. 我在脚本函数中找到了这行代码,但我不知道这意味着什么或如何更改它。 Here is the code: 这是代码:
variable_name = window.document.form_name.page.value; variable_name = window.document.form_name.page.value;
It had an actual form name instead of "form_name" but what exactly is this saying, I get that its setting the variable to something but its the something that I don't understand. 它有一个实际的表单名称,而不是“ form_name”,但是这实际上是在说什么,我知道它将变量设置为某种东西,但它是我不理解的东西。 I'm rather new to script so any help is appreciated! 我是脚本新手,因此不胜感激! Thank you in advance. 先感谢您。
Somewhere in the HTML, you will see something like: 在HTML的某处,您会看到类似以下内容的内容:
<form name="form_name" ...>
...
<input name="page" ...> <!-- or <button> or <textarea> or whatnot -->
...
</form>
window.document.form_name.page.value
is the current value — the currently-entered text — in the form-element named page
. window.document.form_name.page.value
是名为page
的表单元素中的当前值(当前输入的文本)。
The page
is the name of an input field, and value
is looking at the value held inside the input field. 该page
是输入字段的名称,而value
则是查看输入字段中保存的值。 So the above code will store the value (if any) of the page input field (if it exists) into the variable_name
. 因此,以上代码会将页面输入字段(如果存在)的值(如果存在)存储到variable_name
。
This JSFiddle shows how it works . 这个JSFiddle展示了它是如何工作的 。
It's setting variable_name to the value of the page field contained in the form_name form. 它将variable_name设置为form_name表单中包含的页面字段的值。 The field, page, may be hidden or visible. 该字段,页面可能是隐藏的或可见的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.