English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hey Everyone!
I'm working on a javascript project the requires a form, Onclick, variables, and etc. The html document generates a form. When this form is clicked(onClick) it will call to the function in javascript. The function will generate a prompt the allows the user to select a desired bgcolor. This is stored in a variable and changes to document.bgColor. However, when onClick again it will swap back to the original color as designed. This requires another variable. I've tried to do this, but I cant seem to get the program to REFRESH back to normal so it can be used again and again. I'm learning how to program in this language so any help would be greatly appreciated!

Thanks a bunch,
Tim

2006-10-06 08:25:54 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

Hello,

I answered this post for some other user, but here is some basic page that will do what you want. I will explain it in detail in a bit.

=[start "test.html"]============================



Your Color!!!









=[end]================================

The above script, has a simple button, once clicked (using the onClick event) it will change the color to any color you choose from an input field.

Now lets change the above method to just alternate between black and normal...

Remember, HTML renders colors as HEXADECIMAL format, so you have to be aware that the stuff that the browser spits out is HEX color So replace the above script to be the following:

=[start "script only"]============================

=[end]============================

I documented it as much as I can... Notice, that if you wanted to introduce a condtion saying if color1 == color2, both colors should be saved in HEX. Black = #000000 in hex.. ect..

I hope this helped you a bit.

Good Luck

2006-10-09 18:34:34 · answer #1 · answered by ? 6 · 1 0

i always get good javascript help here
http://www.codingforums.com/

2006-10-06 15:34:08 · answer #2 · answered by Anonymous · 0 1

fedest.com, questions and answers