View Full Version : form clearing

01-11-2004, 12:41 PM
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?

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


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

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

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

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

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum