[thelist] [javaScript] removing values from forms

Tris beertastic at gmail.com
Wed Jul 8 05:47:25 CDT 2009

I'm trying to clear an input box is the default value is not changed..
Here's what I've got and can't figure why it's not working...?

  function clearBox(inputName, inputDisplay) {
    if (document.addUser.inputName.value = inputDisplay) {
      document.addUser.inputName.value = '';

And here's a small form

  <form name="addUser" action="' . $_SERVER['PHP_SELF'] . '" method="post">
    <input type="text" name="userName" value="user name"
onclick="javascript: clearBox(\'userName\', \'user name\');"/>
    <input type="text" name="pa55w0rd" value="password"
onclick="javascript: clearBox(\'pa55w0rd\', \'password\');" />

"The only people who don't make mistakes are those who don't do anything"

Give a man a fish and he'll feed himself for a day.
Give a man a religion and he'll starve to death praying for a fish.

`We are what we pretend to be, so we must be careful what we pretend to be.`
Kurt Vonnegut

`When a person can no longer laugh at himself, it is time for others
to laugh at him.`
Thomas Szasz

More information about the thelist mailing list