w3resource logo


JavaScript Form Object - encoding property

JavaScript Form Object : encoding Property

<<PreviousNext>>

Description

The encoding property of the form object refers the type of encoding of the form. It is specified in the enctype attribute of the html <form> tag.

Version

Implemented in JavaScript 1.0

Syntax

form.encoding 

Usage

document.myform.encoding

Where "myform" is the name of the form in the document.

Example of Form Object : encoding property

In the following web document the encoding property of the form object is used to get the type of encoding.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>JavaScript form Object - encoding property example</title>
</head>
<body>
<h1 style="color: red">JavaScript form object : encoding  property</h1>
<h3>Clicking the following button you will get the type of encoding of the form.</h3>
<hr />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[function filename()
function userEncoding(){
var encodingType = document.form1.encoding;
alert(encodingType);
}
//]]>
</script>
<form name="form1" action="post" enctype="multipart-data">
<input type="button" value="Get Encoding" onclick='userEncoding()' />
</form>
</body>
</html>

View the example of form object's encoding property in the browser

Supported Browser

Internet Explorer 7 Firefox 3.6 Google Chrome 7 Safari 5.0.1 Opera 10
Yes Yes Yes Yes Yes

See also :

JavaScript Client side objects, methods, properties.

JavaScript Core objects, methods, properties.



<<PreviousNext>>