fichier démo.html
<! doctype html public - // w3c // dtd html 4.0 transitional // en>
<html>
<adal>
<meta name = Generator Content = Microsoft Visual Studio 7.0>
<Title> </Title>
</ head>
<Script Language = JavaScript>
fonction onload ()
{
var str = window.dialogarguments;
si (str! = Undefined)
{
var arr = str.split (-);
if (arr.length == 2)
{
frmmain.txtname.value = arr [0];
frmmain.txtamount.value = arr [1];
}
}
}
fonction onSubmit ()
{
if (frmmain.txtname.value == || frmmain.txtamount.value ==)
{
alerte (都要填);
retourne false;
}
else if (! Isdigit (frmmain.txtamount.value))
{
alerte (montant 必须是数字);
frmmain.txtamount.focus ();
frmmain.txtamount.select ();
retourne false;
}
autre
{
var odemo = new Demo (frmmain.txtName.value, frmmain.txtamount.value);
window.ReturnValue = Odemo;
window.close ();
}
}
Demo de fonction (nom, montant)
{
this.name = name;
this.amount = montant;
this.toString = function ()
{
renvoie ce.name + - + this.amount;
};
this.fromString = fonction (str)
{
var arr = str.split (-);
if (str ==)
{
this.name =;
this.amount = 0;
}
else if (arr.length == 2)
{
this.name = arr [0];
this.amount = arr [1];
}
autre
{
alerte (格式错误);
retourne false;
}
};
}
fonction isdigit (str)
{
pour (var i = 0; i <str.length; i ++)
{
var ch = str.charat (i);
if (ch <'0' || ch> '9')
{
retourne false;
}
}
Retour Vrai;
}
</cript>
<body onload = onload ()>
<nom de formulaire = frmmain>
<table largeur = 200 align = centre>
<tr>
<td width = 50> nom: </td>
<Td> <Type de Text = Text Name = TxtName size = 10> </td>
</tr>
<tr>
<td width = 50> montant: </td>
<Td> <Type de saisie = Nom de texte = TxTamount size = 10> </td>
</tr>
<tr>
<td align = Center> <Type d'entrée = bouton onClick = onSubmit () value = 确定> </td>
</tr>
</ table>
</ form>
</docy>
</html>