...

View Full Version : form clearing



Murdz
01-11-2004, 11:41 AM
The function clear_text() is called when a user clicks on a text box in my form so that the default value (Type text here) is removed so that only what the user types in in the text box. I can clear it by refering to it specifically, document.form_name.textbox_name.value = ""; to call this I used the onClick="clear_text()" event when a user clicks on the text box. HOWEVER, I am using more then 1 text box and I wish to use the same function for all text box's. So I made it like: onClick="clear_text(this.name)" and the function:

function clear_text(name)
{
document.email(the name of the form).name.value = "";
}


this passes the right variable, it passes the name of the form elementcorreclty and there are no errors but the script still doesnt work. Why is this and how do I fix it? Or must I continue to refer to each text box seperately in this situation?

Garadon
01-11-2004, 12:48 PM
this should do it:


onClick="clear_text(this);"


function clear_text(aObj)
{
aObj.value = "";
}

Murdz
01-12-2004, 02:06 AM
Cheers, thanx dude.

glenngv
01-12-2004, 07:05 AM
why not just use this?

<input onfocus="this.value=''" ...>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum