This script is another neat way to spice up your webpage with JavaScript. Visitors just type their favorite color in the box and click a button. The background is instantly changed to their favorite color!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | /******************************************************* * MYCPLUS Sample Code - https://www.mycplus.com * * * * This code is made available as a service to our * * visitors and is provided strictly for the * * purpose of illustration. * * * * Please direct all inquiries to saqib at mycplus.com * *******************************************************/ <!-- TWO STEPS TO INSTALL TYPE-A-COLOR: 1. Paste the designated script into the HEAD of your HTML document 2. Add the code into the BODY of your HTML document --> <!-- STEP ONE: Paste this script into the HEAD of your HTML document --> <head> <script LANGUAGE="JavaScript"> <!-- Original: Eric Stremming <estremming@hotmail.com> --> <!-- http://www.geocities.com/SunsetStrip/Club/5970/ --> <!--Total Java Scripts 99 - Next Step Software--> <!-- Begin function test(form) { if (form.text.value == "") alert("What\'s your favorite color?") else { document.bgColor=(""+form.text.value+""); } } // End --> </script> <!-- STEP TWO: Add this code to the BODY of your HTML document --> <body> <center> <form> <b>Please enter your favorite<br /> color and then click the button.<br /> <input type="text" name="text"> <input type="button" name="button" value="click for color!" onClick="test(this.form)"> </form> </center> <!-- Script Size: 1.06 KB --> |