Wednesday, January 22, 2025

Pure Magic Form script


…use these to jump around or read it all


[The First Script]
[The Second Script]

Over the past couple of years, I’ve struck up a few online friendships. These are people I know simply through
email and code exchanges. In November of 2001, one of those friends,
Steve Waring dropped me an email with the subject line, “This Is Pure Magic.” Programmers are often guilty of overstatement, so I opened the pages with a grain of salt.

He’s right. That script, which you’ll get here, is pure magic. Further magic is an update to the form script, which you’ll also get here.

The only downfall to the coding is that it only works in MSIE. In Netscape browsers, it’ll throw an error, so if you decide to go ahead and use this script, make sure only MSIE browsers are looking at it. The best way I know to get that effect is a browser choice script.

Let’s take a look.



The First Script

Once again, you’ll need to be looking at this effect in an MSIE browser or you’ll get errors.


The basic concept is that a form is created. The reset button is there but it’s shaded. If any change is made to the form text, the form box turns yellow. Furthermore, the reset button comes alive.

I would suggest using this format in a form where text is already entered into form elements. This would be form where information is carried across pages, such as a shopping cart or survey. Let’s take a look.

See the script in action

Get the script
It’s in full HTML format

The script is written in such a fashion that adding form elements is very easy.
Here’s one of the current form elements:


<input name=ta class=bgwhite size=14 value=”or me” onKeyUp=change(this)>

I’ve bolded the elements that you’ll need to add to any more that you wish to allow the effect. The only real change to make to the script is to the background color of the text boxes. You can change that color in the third line of the script you got just above. Where it reads “yellow,” change it to whatever color you’d like.
Don’t change the code “bgyellow” though. Yeah, I know it reads, “bgyellow,” but if you change it, you’ll need to change many other places as well. Just changing out the color is easiest.



The Second Script

The day after Steve sent this script along, he shot off this version. The script acts the same way except Steve has set up a division that will write text to the page when a change is made. Dig this:

See the script in action

Get the script
It’s in full HTML format


I’ve done some highlighting in this one also. Note the changes for the color scheme. The other bold areas are for the text that changes when the text is changed. I’ve also hit the name of the ID. If you want to add any additional line of text, you’ll need to follow the format laid out in the script.

I’ve added some lines simply by copy and pasting additional lines into the script and then under the HTML form commands. Just make a point of changing out the ID names when you double up the lines.


That’s That

These scripts are great, and really do assist the user anytime a change is made. Thanks Steve, you’re a gentleman.

 

Enjoy!


 


[The First Script]
[The Second Script]

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Popular Articles

Featured