Bentuk tombol , Properti Enctype
Contoh
Kembalikan bagaimana data formulir harus dikodekan sebelum mengirimnya ke server:
var x = document.getElementById("myBtn").formEnctype;
Definisi dan Penggunaan
Properti formEnctype menyetel atau mengembalikan nilai atribut formenctype dari sebuah tombol.
Atribut formenctype menentukan bagaimana form-data harus dikodekan sebelum mengirimnya ke server. Atribut ini menimpa atribut enctype formulir.
Atribut formenctype hanya digunakan untuk tombol dengan type="kirim".
Catatan: Atribut formenctype baru untuk elemen <button> di HTML5.
Dukungan Peramban
Property | |||||
---|---|---|---|---|---|
formEnctype | Yes | 10.0 | Yes | Yes | Yes |
Sintaksis
Kembalikan properti formEnctype:
buttonObject.formEnctype
Setel properti formEnctype:
buttonObject.formEnctype = "application/x-www-form-urlencoded,multipart/form-data,text/plain"
Nilai properti
Value | Description |
---|---|
application/x-www-form-urlencoded | All characters are encoded before sent (this is default) |
multipart/form-data | No characters are encoded. This value is required when you are using forms that have a file upload control |
text/plain | Spaces are converted to "+" symbols, but no special characters are encoded |
Detail Teknis
Nilai Kembali: | Sebuah String, mewakili jenis konten yang digunakan untuk mengirimkan formulir ke server |
---|
Lebih Banyak Contoh
Contoh
Ubah nilai atribut formenctype dari sebuah tombol dari "text/plain" menjadi "application/x-www-form-urlencoded":
document.getElementById("myBtn").formEnctype = "application/x-www-form-urlencoded";
Contoh
Contoh lain untuk mengembalikan properti formEnctype:
var x =
document.getElementById("myBtn").formEnctype;
Halaman Terkait
Referensi HTML: HTML <button> atribut formenctype
Objek Tombol