Properti HTMLInputElement.size
menetapkan atau mengembalikan atribut SIZE elemen INPUT HTML.
Sintaks:
inputObj.size = value
inputObj.size
value adalah number (unsigned long).
Contoh di bawah ini mengembalikan nilai atribut SIZE elemen INPUT ber-NAME 'username':
<FORM METHOD="POST" ACTION="yourCGIURL">
<FIELDSET>
<LEGEND>Login</LEGEND>
Username : <INPUT TYPE="text" NAME="username" SIZE="40">
Password : <INPUT TYPE="password" NAME="password" SIZE="40">
<INPUT TYPE="submit" VALUE="Log in">
</FIELDSET>
</FORM>
<SCRIPT TYPE="text/javascript">
var inputObj = document.getElementsByTagName("input")[0];
alert(inputObj.size); // 40
</SCRIPT>
Contoh di bawah ini menetapkan atribut SIZE kepada elemen INPUT ber-NAME 'username':
<FORM METHOD="POST" ACTION="yourCGIURL">
<FIELDSET>
<LEGEND>Login</LEGEND>
Username : <INPUT TYPE="text" NAME="username">
Password : <INPUT TYPE="password" NAME="password" SIZE="40">
<INPUT TYPE="submit" VALUE="Log in">
</FIELDSET>
</FORM>
<SCRIPT TYPE="text/javascript">
var inputObj = document.getElementsByTagName("input")[0];
inputObj.size = 40;
</SCRIPT>
Elemen INPUT ber-NAME 'username' di atas akan menjadi:
<INPUT TYPE="text" NAME="username" SIZE="40">