For clearing the form near is distinctive button Reset, by pressing on which the given forms come reverse in a reference price . If to enter the data into the appearance , and then to press such button all entered data determination return to initial assessment which was before say of the user. so from a position of convenience button Reset brings only damage , in detail it is possible to press carelessly it(her) and to unsound results of input. Nevertheless, sometimes there is a trouble (task) of clearing of the outline by resources of JavaScript. For this function the mode reset is used, he is practical as follows (an example 1).
Example 1. employ of a method retune
document.forms [" a name of the shape "] .reset () before
document.forms.eiy oi?iu.reorganize ()
Let's consider the following dilemma (task) anywhere clearing of the appearance can exist useful slightly . For a site predominantly consisting of clauses(articles), because useful count the shape of a spelling of the customer comment can serve. now there are two key approaches.
inside the former case, following input of the textbook and burning button suggest , the records are sent on the server. subsequently the current page is reloaded into a browser, near is again same part (article), but already by the further comment, is usual inside the underside of page. The it is more additional comments, the the text is added slowly overloaded and the more occasion to boast to expect at addition new.
into the following case, following sending the form of the note on the server, the new windowpane in which the program - ia?aaio?ee of the figures is started opens plus is informed, that the wording is additional (or is not new and why). habitual ia?acaa?ocee pages accomplish not arise to be convinced, that with the comment that's all right, it is probable to build it <physically >. Thus the form alone is not cleared, and it can confuse the user. into fact he once again to itself(himself) determination puzzle, it has twisted out at him(it) whether or not to fire the note on the server. Here just payment of the form with help JavaScript also is useful.
qualities and demerits are intrinsic in every approach, now we shall not go into niceties and assort them. We shall attempt to affect better a method rearrange in practice, using the succeeding described approach to addition of the comment.
For creation of a fresh window we shall utilize a manner window.unfasten which allows to control display of parameters of a glass . In picky , we shall set by him(it) the rigid bulk 400 on 300 pixels, we shall sterile (remove) the menu, carpet of scrolling and a status saloon . It is important to give a new transom any name to include an break to assume (remove) the text into the specified window, instead of recent . In an example the window is called popmsg.
Let's use that, that oaa structure has issue target, he works similarly to boundary for frames, namely, tons result of performance of the server program precise in stricture action, into the situate window before the edge . Having specific value goal =popmsg, we redirect a conclusion to a fresh window by a name popmsg, fashioned at facilitate JavaScript.
At sending the form on the server event onSubmit on which we <fall > the meaning popupMsg is generated. This function checks, whether all figures are entered and during case of success creates a new-fangled window by a name popmsg somewhere the consequence of act of the server program is encumbered . Then the form of the observation is clean by a method rearrange (an illustration 2).
Example 2. submission of reimbursement of the form
<html>
<carcass >
<script language = "JavaScript">
task popupMsg (f) {
tolerable = 1
msg = " "
// during the establishment we verify the numbers on a correctness.
but (! f.name.assessment ) {ok = 0; msg = "Eiy\n"}
but (! f.textbook .value) {passable = 0; msg + = " the Text of the observation "}
if (ok) {
windowpane .open ("", popmsg "," breadth =400, height=300, position =0, menubar=0, position =0 resizable=0 directories=0 toolbar=0 ")
f.present ()
f.reset ()
} else alert (" the following aaiiua:\n " + msg are not specified)
}
</lettering >
<form process =POST exploit =/cgi-bin/addcomment.cgi target=popmsg name=remark onSubmit = " popupMsg (this); return false ">
<stall width=100 % margin =0 cellspacing=0 cellpadding=4>
<tr>
<td align=precise valign=zenith > the Name </td>
<td> <say name=name maxlength=50 amount =20 type=copy > </td>
</tr>
<tr>
<td align=precise valign=summit > E-mail </td>
<td> <contribution name=email maxlength=50 amount =20 type=copy > </td>
</tr>
<tr>
<td align=exact valign=pinnacle > the commentary </td>
<td> <textarea name=passage cols=45 rows=10> </textarea> </td>
</tr>
<tr>
<td> *nbsp; </td>
<td> <effort type=propose value = " To add the comment "> </td>
</tr>
<tr>
</tr>
</stand >
</form>
</corpse >
</html>
For convenience, in a dub of job popupMsg the keyword this is second-hand , it allows to address to the figure through quarrel f, specifying on the form.

|