Getting value GET OR POST variable using JavaScript?

前端 未结 9 1572
一个人的身影
一个人的身影 2020-11-27 05:59

How to get value of the get or post variable on page load using JavaScript?

9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-27 06:37

    The simplest technique:

    If your form action attribute is omitted, you can send a form to the same HTML file without actually using a GET HTTP access, just by using onClick on the button used for submitting the form. Then the form fields are in the elements array document.FormName.elements . Each element in that array has a value attribute containing the string the user provided (For INPUT elements). It also has id and name attributes, containing the id and/or name provided in the form child elements.

提交回复
热议问题