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;
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. I'm rather new to script so any help is appreciated! Thank you in advance.
Somewhere in the HTML, you will see something like:
<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
.
The page
is the name of an input field, and value
is looking at the value held inside the input field. So the above code will store the value (if any) of the page input field (if it exists) into the variable_name
.
This JSFiddle shows how it works .
It's setting variable_name to the value of the page field contained in the form_name form. The field, page, may be hidden or visible.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.