Metoda atrybut HTML DOM Formularz
Definicja i Wykorzystanie
Metoda zestawy własności lub zwraca metodę formularz wartości atrybutów.
Sposób formułowania atrybutów jak wysłać dane formularza (dane formularzy złożonych na adres podany w atrybucie akcji).
gramatyka
formObject.method=value
Atrybut metoda może mieć następujące wartości:
值 | 描述 |
---|---|
get | 在 URL 中添加表单数据: URL?name=value&name=value (默认) |
post | 使用 http post方法提交表单数据 |
Pomoc Browser
Wszystkie główne przeglądarki obsługują atrybut metody
Uwaga: Internet Explorer, jeśli nie ma zdefiniowany atrybut metoda zwraca "get" (ustawienie domyślne), inne przeglądarki nie zwraca wartości.
Przykłady
Przykłady
Zwraca tworzą metody transmisji danych:
<html>
<body>
<form id="frm1" action="form_action.html" method="get">
First name: <input type="text" name="fname" value="Donald"><br>
Last name: <input type="text" name="lname" value="Duck"><br>
<input type="submit" value="Submit">
</form>
<script>
document.write(document.getElementById("frm1").method);
</script>
</body>
</html>
<body>
<form id="frm1" action="form_action.html" method="get">
First name: <input type="text" name="fname" value="Donald"><br>
Last name: <input type="text" name="lname" value="Duck"><br>
<input type="submit" value="Submit">
</form>
<script>
document.write(document.getElementById("frm1").method);
</script>
</body>
</html>
Przykłady wyżej wyjścia:
get
Spróbuj »
forma obiektu