spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

Developer News
Cisco Lawsuit: A Test for the GPL?
Shifts for Enterprise Linux, Green Networks in '09
Gifts for All in Linux 2.6.28
JavaScript Tip of the Week for May 20, 1996: Using forms and windows together

That's all great, but where's the fun in windows? Add forms and windows suddenly become more useful; I have used a "Madlibs" like example to show this. Quickly fill in the form, and then press the button to see how it all works.

Plural Noun:
Part of body (plural):
Verb:
Name:
Name of Polictician:
Adjective:
Article of Clothing:
Article of Clothing:
Occupation:
Noun:
Noun:
Noun:
Animal (plural):
A Food:



Neat, huh? You all know how to create a window by now but do you know how to write to a window, and send form data to a specific window? First you have to create a form and give each object in the form a name. In this example, there are 14 input boxes, each named input1, input2, etc. After the user fills in the boxes, the data is sent to a function by pressing the Create Window button. The code for this is simple:
    <INPUT TYPE="button"
           VALUE="Create Window"
           onClick="create(this.form)">

The code sends the form data to the create function, which then puts all the form input data and text into a long string variable text. Now this is where many people may run into a problem. For some yet unkown reason, JavaScript will return an "undetermined string literal" error message if a string is too long, say 254 characters or more. Now there's any easy fix for this. Just split up the string into smaller parts with addition signs, which you have to do anyway because of the form inputs:
    text = ("Friends, Romans, "  + form.input1.value +  " lend me your "
            + form.input2.value +  "; ");
   

Now you must create a blank window. Then take the string text and write it to that window:
    msgWindow=window.open("", <-- Notice a URL is not required
                          "displayWindow",
                          "toolbar=no,
                          width=375,
                          height=480,
                          directories=no,
                          status=no,
                          scrollbars=yes,
                          resize=no,
                          menubar=no")
    msgWindow.document.write(text)
    msgWindow.document.close()

As you can see, a simple document.write is all that you need to write the data in text to the window, but you do have to refer to the window by name. I hope you can find some more creative uses for windows and frames than I have, because that's the beauty of letting everybody in on HTML and JavaScript programming. Source

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Overview of Popular JavaScript Frameworks - ASP.NET AJAX · An Introduction to 3D · Email Marketing Terms to Know
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Configuring Anonymous Dialog Security in SQL Server 2005 Express Service Broker Conversation · OpenVPN: Revoking Access and Expanding Management Options · Connecticut Town Lays Groundwork for Merged School, Municipal VoIP Network