Re: javascript functions passing arguments
by "Peter Newton" <c-newton(at)ihug.co.nz>
|
Date: |
Tue, 6 Mar 2001 23:21:08 +1300 |
To: |
<hwg-languages(at)hwg.org> |
References: |
hotmail |
|
todo: View
Thread,
Original
|
|
Thanks Two-Bits,
I've applied your code to textareas etc and it works just fine
I'm not quite sure about the following line, what is this line saying?
typeof(input.defaultValue)=="undefined"
Many thanks
Peter Newton
-----------------------------------------
> dont worry about form or input names...you can just pass "this" to the
> function. also, try building off the input object to hold the original
> value. try these generic functions:
>
> <SCRIPT>
> <!--
> function hideDefault(input){
> if(typeof(input.defaultValue)=="undefined")
> input.defaultValue = input.value;
> if(input.value == input.defaultValue)
> input.value = "";
> return true;
> }
> function showDefault(input){
> if(input.value == "" && typeof(input.defaultValue)!="undefined")
> input.value = input.defaultValue;
> return true;
> }
> //-->
> </SCRIPT>
>
> then your fields are as easy as this:
>
> <FORM>
> <INPUT onFocus="return hideDefault(this);"
> onBlur="return showDefault(this);"
> value="Type your full name here"><BR>
> <INPUT onFocus="return hideDefault(this);"
> onBlur="return showDefault(this);"
> value="Type your full address here"><BR>
> </FORM>
>
> Good luck - Two-Bits
HWG: hwg-languages mailing list archives,
maintained by Webmasters @ IWA