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

Need help in revisions to expression engine website, Revisions to Expressio...

Revisions to Expression Engine website I am handling a website created from Expression Engine framework and need a few revisions completed. I will attempt to describe the revisi

I need help in woocommerce and wordpress extra developemnt, I need help in ...

I need help in woocommerce and wordpress extra developemnt needed on existing website I have an existing website which I want some extra development on. It's a pretty simple cus

I need help in crowd funding website, Crowd Funding Website We would lik...

Crowd Funding Website We would like to identical a site, with exact features, functionality and details. Let us know if you need more details. Desired Skills are PHP, Web

Internet address, Addresses are necessary for virtually everything we do on...

Addresses are necessary for virtually everything we do on the Internet. In TCP/IP the IP is a mechanism for providing addresses for computers on the Internet. Internet addresses co

Seeking for a prestashop car parts theme and installation, Hello, Im curren...

Hello, Im currently seeking for a prestashop car parts theme + installation onto my hosting account. Need someone who will be able to help with any other needs later on once we sta

Need help -real estate website and mobile apps ios & android, Real Estate W...

Real Estate Website and Mobile apps(iOS & Android) High Level Project Description I am seeking to create user friendly mobile responsive Real Estate website as well as Mobile

Need help in drupal commerce payments and checkout solutions, Drupal commer...

Drupal commerce payments/checkout solutions A current Drupal commerce website using PayPal as the payment method. Want to combine check out by amazon and sagepay which signifies

Need help for telerik controls integration into ie8, Need help for Telerik ...

Need help for Telerik Controls Integration into IE8 We are in search of an experts at integration telerik controls into IE8. We have experienced a few issues as well as we would

Explain best user interface design guidelines, Question: The best user ...

Question: The best user interface design guidelines are guidelines that given high level and widely applicable principles. A set of such guidelines is as follows: (i) Know

Looking for web programmer for start-up, Looking for web programmer for sta...

Looking for web programmer for start-up (B2C platform plus app, similar Airbnb style) We just started besides need a web programmer who is intended to code only. Desired Skil

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