So with all that code we now have a JavaScript Form object that we can use to create forms and add them into a web page. The code that we have so far does nothing though until such time as we actually run it.
Just exactly what calls we would make in creating a form depends on just what we want our form to contain. This is going to be different for each form and so we can only look at an example of the sort of code that would generate a form in order to see how it works.
var f = new Form('next.php','post','','My Form');
f.addHidden('firsthide','one');
f.addInput('text','Your Name','yname','Steve','r');
f.addInput('radio','Male','sex','M','c');
f.addInput('radio','Female','sex','F','');
f.addTextarea('Message','mess','some text goes in here','');
f.addInput('submit','','go','Go','');
f.addForm('myform');
The first statement here is how we call our object constructor to create our form object. The keyowrd new is what tells JavaScript that we are creating a new object rather than calling a function.
The statements following add a hidden field, a readonly text input field, a group of two radio buttons with the first one selected, a textarea and a submit button to the form and then add it into the web page where the id="myform" reference appears.
Using the same Form object we can create as many different forms as we like with whatever form fields in each that we need and then add them whereever we want in the page.
The one thing that none of the code does with our form is to specify how any of it should look but there will be sufficient tags and ids in the form itself to be able to specify all of the information regarding how you want the form to look in your CSS.
