HTMLGoodies
The ultimate html resource
Earthweb.com


About the Double-Underlined Links


Become a Partner




Search Clipart.com:



internet.commerce















HTML Goodies : Beyond HTML : Javascript : The Script Tips: HTML Goodies: Script Tip: Week 24

HTML GOODIES TO GO NEWSLETTER


Other Related Newsletters

HTML Goodies: Script Tip: Week 24


By Joe Burns


Thy Name is Tip...

Okay, we understand the top, the prompts, and we understand the bottom, the HTML form flags. Now let's hit the guts of this script. The function.


See the Guestbook in Action


Here's the Code for the Guestbook


The function looks like this:

<SCRIPT LANGUAGE="javascript">

function verify()
{
var OpenWindow=window.open("", "newwin", "height=300,width=300");
OpenWindow.document.write("<HTML>")
OpenWindow.document.write("<TITLE>Thanks for Writing</TITLE>")
OpenWindow.document.write("<BODY BGCOLOR='ffffcc'>")
OpenWindow.document.write("<CENTER>")
OpenWindow.document.write("Thank you <B>" + name + "</B> from <B>" +email+ "</B><P>")
OpenWindow.document.write("Your message <P><I>" + document.gbookForm.maintext.value + "</I><P>")
OpenWindow.document.write("from " + name + " / " +email+ "<P>")
OpenWindow.document.write("will be sent along when you close this window.<P>")
OpenWindow.document.write("<CENTER>")
OpenWindow.document.write("<FORM><INPUT TYPE='button' VALUE='Close Window' onClick='self.close()'></FORM>")
OpenWindow.document.write("</CENTER>")
OpenWindow.document.write("</HTML>")
}
</SCRIPT>

If you're an avid reader of HTML Goodies, then you probably recognize the format. The function, named verify(), is surrounding JavaScript that will open a new window and fill it with text. I have an entire tutorial on just that right here.

The function is called for when you click on the HTML form button. Remember that onClick="verify()"?

Once clicked, the variable "OpenWindow" is assigned the properties of the new window. Then, one after the other, lines of HTML are filled in. But to get the effect that the HTML page that is being filled in was created from the e-mail, we start to use the text strings that we gathered from the two prompts, namely "name" and "e-mail." Look at this line:

OpenWindow.document.write("Thank you <B>" + name + "</B> from <B>" +email+ "</B><P>")

See how the text strings are being placed to give the effect that the window was opened just for the user? Then this line of code:

OpenWindow.document.write("Your message <P><I>" + document.gbookForm.maintext.value + "</I><P>")

...grabs the text the user wrote into the TEXTAREA box and displays it. And it is the display, I think, that makes this little window come alive. See how the first time the name and e-mail are displayed they're in bold and the text from the TEXTAREA box is italic? I think that really looks great. It gives the impression that the little window is a form created off of the e-mail itself rather than a simple representation of the information given to the computer.

Then this line of code:

OpenWindow.document.write("<FORM><INPUT TYPE='button' VALUE='Close Window' onClick='self.close()'></FORM>")

...creates a great button that closes the window. The "self.close" object.method statement does the trick. Great effect.

Finally, the ending HTML commands are written to the page and the function is closed.

And another script comes to an end. Feel free to use the script just as it is or add or take away as you see fit. Some people like the prompts, some don't. It's up to you. I happen to like them.

Since we're done with this one, let's get back to the that running digital clock. I fixed it!

Next Week: The Digital Clock Revisited

     Do YOU have a Script Tip you'd like to share? How about suggesting a Script Tip to write about? I'd love to hear it. Write me at: jburns@htmlgoodies.com.


Learn to write your own JavaScripts with the
HTML Goodies 30-Step Primer Series
and take the knowledge home with you in
JavaScript Goodies!


You can find many other uses for JavaScript
on your Web pages here!

Tools:
Add htmlgoodies.com to your favorites
Add htmlgoodies.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

IT Management Networking & Communications Web Development Hardware & Systems Software Development Earthwebnews.com



JupiterOnlineMedia

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

Solutions
Whitepapers and eBooks
IBM Whitepaper: Service Component Architecture Enabling XML Web Services for Java Programmers
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Intel Article: Using Power & Display Context in the Intel Mobile Platform SDK
Internet.com eBook: Real Life Rails
IBM SCA Center Article: Simplifying Composite Applications with Service Component Architecture
Intel PDF: Quad-Core Impacts More Than the Data Center
Internet.com eBook: The Pros and Cons of Outsourcing
Go Parallel Article: Scalable Parallelism with Intel(R) Threading Building Blocks
Intel PDF: Analysis of Early Testing of Intel vPro in Large IT Departments
Internet.com eBook: Best Practices for Developing a Web Site
Intel PDF: IT Agility through Automated, Policy-based Virtual Infrastructure
IBM CIO Whitepaper: The New Information Agenda. Do You Have One?
Microsoft Article: BitLocker Brings Encryption to Windows Server 2008
IBM Whitepaper: Service Component Architecture & Java EE Integration
Microsoft Article: RODCs Transform Branch Office Security
Go Parallel Article: James Reinders on the Intel Parallel Studio Beta Program
Avaya Article: Advancing the State of the Art in Customer Service
IBM Whitepaper: How are other CIOs driving growth?
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Avaya Article: Avaya AE Services Provide Rapid Telephony Integration with Facebook
Go Parallel Article: Getting Started with TBB on Windows
HP eBook: Storage Networking , Part 1
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Go Parallel Video: Intel(R) Threading Building Blocks: A New Method for Threading in C++
HP Video: Is Your Data Center Ready for a Real World Disaster?
HP On Demand Webcast: Virtualization in Action
Go Parallel Video: Performance and Threading Tools for Game Developers
Rackspace Hosting Center: Customer Videos
Intel vPro Developer Virtual Bootcamp
HP Disaster-Proof Solutions eSeminar
HP On Demand Webcast: Discover the Benefits of Virtualization
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Download: IBM WebSphere Application Server V7.0 Feature Pack for Service Component Architecture
Actuate Download: Free Visual Report Development Tool
Microsoft Download: Silverlight 2 Software Development Kit Beta 2
30-Day Trial: SPAMfighter Exchange Module
Red Gate Download: SQL Toolbelt
IBM SCA Download: Start Building SCA Applications Today
Iron Speed Designer Application Generator
Microsoft Download: Silverlight 2 Beta 2 Runtime
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
IBM IT Innovation Article: Green Servers Provide a Competitive Advantage
Microsoft Article: Expression Web 2 for PHP Developers--Simplify Your PHP Applications
Featured Algorithm: Intel Threading Building Blocks - parallel_reduce
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES