Archive for October, 2007

637Chapter 21The Form and Related ObjectsA (Web server logs) common sense

Saturday, October 27th, 2007

637Chapter 21The Form and Related ObjectsA common sense approach to the situation calls for a script to perform the submission (viathe form.submit()method) and then navigate to another page that does the Thank You. Here is such a scenario from inside a function triggered by a click of a link surrounding a nice, graphical Submit button: function doSubmit() { document.forms[0].submit(); location.href = thanks.html ; } The problem is that when another statement executes immediately after the form.submit() method, the submission is canceled. In other words, the script does not wait for the submis- sion to complete itself and verify to the browser that all is well (even though the browserappears to know how to track that information given the status bar feedback during submis- sion). The point is, because JavaScript does not provide an event that is triggered by a suc- cessful submission, there is no sure-fire way to display your own Thank You page. Don t be tempted by the window.setTimeout() method to change the location after somenumber of milliseconds following the form.submit()method. You cannot predict how fastthe network and/or server is for every visitor. If the submission does not complete before thetimeout ends, the submission is still canceled even if it is partially complete. Form element arraysStarting with NN2 and IE4, document object models provide a feature that is beneficial to a lotof scripters. If you create a series of like-named objects, they automatically become an arrayof objects accessible via array syntax (see Chapter 7). This is particularly helpful when youcreate forms with columns and rows of fields, such as in an order form. By assigning the samename to all fields in a column, you can employ forloops to cycle through each row using theloop index as an array index. As an example, the following code shows a typical function that calculates the total for anorder form row (and calls another custom function to format the value): function extendRows(form) { for (var i = 0; i < Qty.length; i++) { var rowSum = form.Qty[i].value * form.Price[i].value; form.Total[i].value = formatNum(rowSum,2); } } All fields in the Qty column are named Qty. The item in the first row has an array index valueof zero and is addressed as form.Qty[i]. About element objectsWhile this chapter focuses strictly on the formelement as a container of controls, the nextthree chapters discuss different types of controls that nest inside a form. Many of these con- trols share the same HTML tag: . Only the typeattribute of the tag deter- mines whether the browser shows you a clickable button, a checkbox, a text field, or so on. The fact that one element has so many guises makes the system seem illogical at times toscripters. An inputelement has some attributes (and corresponding scriptable object properties) thatsimply don t apply to every type of form control. For example, while the maxLengthpropertyform
If you are looking for cheap and quality webhost to host and run your website check Jboss Web Hosting services.

636Part IIIDocument Objects ReferenceThe last attribute of note (Linux web host)

Friday, October 26th, 2007

Jetty web server - 635Chapter 21The Form and Related Objects .Pass the

Friday, October 26th, 2007

634Part IIIDocument Objects ReferenceAnother version of the thisparameter (Web site construction)

Thursday, October 25th, 2007

633Chapter 21The Form and (Web hosting top) Related ObjectsFigure 21-1:Controls pass

Thursday, October 25th, 2007

632Part IIIDocument (Web design tools) Objects Referencewhich represents a reference to

Wednesday, October 24th, 2007

631Chapter 21The Form and Related (Sex offenders web site) Objectspopular but inflexible

Wednesday, October 24th, 2007

630Part IIIDocument Objects Referenceform ObjectFor HTML element (Web hosting contract) properties,

Wednesday, October 24th, 2007

The Form andRelated ObjectsPrior to the advent of (Anonymous web server)

Tuesday, October 23rd, 2007

Web hosting company - 627Chapter 20Image, Area, and Map Objects Related Items:areaelement

Tuesday, October 23rd, 2007