Forms, PHP Web Programming

Assignment Help:

Each of form in a document develops a form object. As a document can have more than one form, Form objects are stored in an array called forms.

Forms Array

By using the forms[ ] array we access each of the Form object in turn and illustrates the value of its name property in message box. Let us have a look at an instance that uses the forms array. Here we have a page along three forms on it.

<HTML>                                                                                                                                          

<HEAD>                                                                                                                                            

<SCRIPT LANGUAGE=JavaScript>                                                                                         

function window_onload()                                                                                                           

{                                                                                                                                                   

var numberForms = document.forms.length;                                                                          

var formIndex;                                                                                                                          

for (formIndex = 0; formIndex < numberForms; formIndex++)                                          

{                                                                                                                                               

alert(document.forms[formIndex].name

}                                                                                                                                                

}         

</SCRIPT>

</HEAD>                                                                                                                                           

<BODY LANGUAGE=JavaScript onLoad="window_onload()">                                               

<FORM NAME="form1">                                                                                                        

<P>This is inside form1</P>

</FORM>                                                                                                                                   

<FORM NAME="form2">                                                                                                      

<P>This is inside form2</P>

</FORM>                                                                                                                                    

<FORM NAME="form3">                                                                                                     

<P>This is inside form3</P>                                                                                          

</FORM>                                                                                                                                   

</BODY>                                                                                                                                          

</HTML>         

In the body of the page we define three forms. Each of the form is provided name, and contains a paragraph of text. In the definition of the <BODY> tag, the                               

window_onload( ) function is connected to the window object's onLoad event handler.            

<BODY LANGUAGE=JavaScript onLoad="return

window_onload( )">                                                                                                                     

This means that while the page is loaded, our window_onload() function shall be called. The window_onload( ) function is described in a script block in the HEAD of the page. In this function we loop through the forms[ ] array. Just like other JavaScript array, the forms[ ] array contain length property which we can employ to determine how several times we have to loop. In fact, as we know how many forms there are, we could just write the number in. Though, here we are also demonstrating length property, as then it is easier to add to the array without change the function. Generalizing your code such as is a good practice to follow.                      

.

The function begins through getting the number of Form objects in the forms array & stores it in the variable numberForms.

function window_onload( )

{

var numberForms = document.forms.length;

After that we define a variable, formIndex, to be utilized in our for loop. After this comes for loop itself.

for (formIndex = 0; formIndex < numberForms; formIndex++)

{

alert(document.forms[formIndex].name);

}

Keep in mind that as the indices for arrays begins at zero, our loop have to go from an index of 0 to index of number Forms - 1. We do this through initializing the formIndex variable to zero, & setting the condition of for loop to formIndex < numberForms.

In the for loop's code, we pass the index of the wished form (i.e., formIndex) to document.forms[ ], that gives us the Form object at that array index in the forms array. To access Form object's name property, we put a dot at the ending and the name of the property, name.


Related Discussions:- Forms

I need help in redesign website, I need help in Redesign Website - Build ou...

I need help in Redesign Website - Build out ONLY I need somebody to redesign my client's website. I have by now created the designs in Photoshop as well as just need someone who ca

Create a simple php shopping cart, The system should be able to secure crea...

The system should be able to secure creating client accounts, integrate the notion of administrator and have a shopping cart. You should use PDO class for communications with th

I want a google map programming using php, I need Google Map Programming ...

I need Google Map Programming We are in search of a PHP JavaScript Programmer to cultivate an interactive Google Map. We require the subsequent completed. a) We have 30,00

I need help in image uploading and simple resizing, I need help in Image Up...

I need help in Image Uploading and Simple Resizing / Frame Selection We need someone to implement a way for our writers to upload an image and have it automatically resize to on

Vbscript basics, It is a powerful & easy to learn tool which can be used to...

It is a powerful & easy to learn tool which can be used to insert interaction to your Web pages. The Web browser attains scripts along the rest of the Web document. The browser

Require a expert ruby on rails developer for ios and android, Require a exp...

Require a experts in Ruby on Rails developer for iOS and Android API I have a mobile app on iOS as well as Android which runs on a Ruby on Rails API. I would like to make some e

Distributed course registration system, Webservice Implementation of the Di...

Webservice Implementation of the Distributed Course Registration System In this assignment, you are going to implement the Distributed Course Registration System (DCRS) from Assig

Need help in changes in current pos system, Changes in Current POS system ...

Changes in Current POS system We have a POS system now working fine. We need little addon function, field as well as reports to make it more perfect We likewise want the same

We need help in likenet upgrade - slot machine, We need help in Likenet Upg...

We need help in Likenet Upgrade - Slot machine LikeNet Upgrade - Slot Machine Users is able to gamble their credits A visual/engaging/animated slot machine. Looks merely l

Bowline website for it security company, Bowline Website I do like to ha...

Bowline Website I do like to have a website created for my company. It is an IT Security Company. The target spectators is in Africa. I am seeking at about 25 pages to be develo

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd