Contoh penggunaan
<skrip type="teks/javascript" src="../scripts/prototype.js"></script>
<skrip tipe="teks/javascript">
var bilah kemajuan;
/**//*
* Fungsi: login admin
*/
fungsi Login Pengguna()
{
//Verifikasi kontrol halaman
var checkform = CheckForm baru();
if(!checkform.checkForm(document.getElementById('formLogin'))) mengembalikan false;
//Mulai mengirimkan data
progressBar = ProgressBar baru();
progressBar.SetStatus("Mengirim data ke server.");
var url = "../admin.do";
var pars = "action=Login&nama pengguna=" + $F('nama pengguna') + "&kata sandi=" + $F('kata sandi') + "&rnd=" +$F('rnd');
var myAjax = Ajax.Permintaan baru(
url,
{metode: 'posting', parameter: pars, onComplete: UserLogin_CallBack}
);
}
/**//*
* Fungsi: login admin - Panggilan Balik
*/
fungsi UserLogin_CallBack (Permintaan asli)
{
var objXml = originalRequest.responseXML;
//alert(asliRequest.responseTEXT);
mencoba
{
if(objXml.getElementsByTagName("return")[0].firstChild.nodeValue == "true")
{
progresBar.isNeedConfirmButton = false;
progresBar.isNeedProgressBar = benar;
progresBar.SetStatus("<img src='../images/error.gif' align='absmiddle'> Login berhasil, memuat, harap tunggu..");
//login sukses
location.href='admin_index.htm';
}
kalau tidak
{
progresBar.isNeedConfirmButton = benar;
progresBar.isNeedProgressBar = salah;
progresBar.focusItem = "nama pengguna";
progresBar.SetStatus("<img src='../images/error.gif' align='absmiddle'> Maaf, gagal masuk!" + objXml.getElementsByTagName("msg")[0].firstChild.nodeValue
$ ('btnOK').disabled = false;
}
}
menangkap (salah)
{
progresBar.isNeedConfirmButton = benar;
progresBar.isNeedProgressBar = salah;
progresBar.focusItem = "nama pengguna";
progresBar.SetStatus("<img src='../images/error.gif' align='absmiddle'> Maaf, login gagal!" + err.message);
$('btnOK').disabled = false;
}
}
</skrip>
<lebar tabel="100%" border="0" cellpadding="3" Cellspacing="0">
<tr>
<td colspan="3" tinggi="30"></td>
</tr>
<tr>
<td width="21%">Nama pengguna:</td>
<td colspan="2">
<input type="text" tabindex="1" id="nama pengguna" name="nama pengguna" chname="nama pengguna" notempty="true" size="20" style="width:180px;" >
</tr>
<tr>
<td>Kata sandi:</td>
<td colspan="2"><input type="password" tabindex="2" id="password" name="password" chname="password" notempty="true" size="20" style="width: 180 piksel;" /></td>
</tr>
<tr>
<td>Kode verifikasi:</td>
<td colspan="2">
<input type="text" style="width:120px;" id="rnd" tabindex="3" chname="Kode verifikasi" class="input_1" notempty="true" onKeyUp="value=value.replace( /[^d]/g,'')"/>
<img alt="Kode verifikasi" src="../rnd.do?type=admin_rnd" border="0" usemap="absmiddle"/></td>
</tr>
<tr>
<td class="putih"> </td>
<td width="22%"><input type="submit" Class="input_1" id="btnOK" value="Login" tabindex="4"></td>
<td width="57%"><input type="reset" Class="input_1" value="Reset"></td>
</tr>
<tr>
<td colspan="3" tinggi="2"></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
</tabel>
unduh prototype.js http://edzh.com/scripts/prototype.js