Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2008
    Location
    NEW YOrk
    Posts
    18
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Exclamation default text on external file

    Hi


    I'm having a issue because I need to add a default text in a input field. The problem is that I know how to do it on inline stile, but no idea how to do it external...



    This is what I have:

    <input type="text" name="myfield" value="Type Your Name" onclick="clickclear(this, 'Type Your Name')" onblur="clickrecall(this,'Type Your Name')" />


    OnClick the link value should disappear only when is 'Type Your Name'

  • #2
    Regular Coder ninnypants's Avatar
    Join Date
    Apr 2008
    Location
    Utah
    Posts
    504
    Thanks
    10
    Thanked 47 Times in 47 Posts
    You would set a default text for an element with JavaScript like this
    Code:
    document.formname.elementname.value = 'type your name';
    I would also suggest changing your function that clears the text from being on click to onfocus because main user use the tab button to navigate forms or even the entire page.
    Code:
    <input type="text" name="myfield" value="Type Your Name" onfocus="clickclear(this, 'Type Your Name')" onblur="clickrecall(this,'Type Your Name')" />

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Post your clickclear and clickrecall functions.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •