Buscar

Form Input Sederhana di Javascript

Saya punya contoh script bikin form input yang paling sederhana menggunakan javascript....
Disimak yuu :)
<script language="Javascript">
function fungsitebak() {
 var val1=document.kirim.input1.value
 if (val1%2==0){
  document.kirim.input2.value="BILANGAN GENAP";
 }else{
  document.kirim.input2.value="BILANGAN GANJIL";
 }
}

</script>


<form method="post" name="kirim">
<table style="font-family: Verdana, Geneva, sans-serif; font-size: 12px; width: 354px;">
 <tbody>
<tr>
    <td align="center" colspan="3" height="30" width="137">TEBAK BILANGAN<br />
<hr />
</td>
  </tr>
<tr>
    <td height="30" width="137">Masukan Bilangan</td>
    <td width="8">:</td>
    <td width="192"><input name="input1" size="20" type="text" /></td>
  </tr>
<tr>
    <td height="30"></td>
    <td></td>
    <td><input name="button1" onclick="fungsitebak()" type="button" value="TEBAK" /></td>
  </tr>
<tr>
    <td height="30">Merupakan Bilangan</td>
    <td>:</td>
    <td><input disabled="disabled" name="input2" size="20" style="background-color: #cccccc;" type="text" /></td>
  </tr>
</tbody></table>
</form>
Outputnya kayak gini :

Semoga bermanfaat yaaa :)

0 comments:

Posting Komentar