text disapear in textbox

Discussion in 'HTML & Website Design' started by MajHate, Nov 5, 2008.

  1. #1
    Hello,

    I am trying to make the text in an html text box disappear when the user clicks on it. Does anyone know how to do this? I'm guessing there would be some java script involved, but I am not sure. Also does anyone know how to disable a text box so the user cannot type into it?

    Thank You,
    Jason
     
    MajHate, Nov 5, 2008 IP
  2. sampathsl

    sampathsl Guest

    Messages:
    861
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    copy this Java script in the HTML head

    <script language="Javascript">
    <!--

    function doClear(theText)
    {
    if (theText.value == theText.defaultValue)
    {
    theText.value = ""
    }
    }
    //-->
    </script>

    =================================
    Please do this in your html body section :
    <form>
    <input type="text" size=15 value="Enter name" onFocus="doClear(this)">
    </form>
     
    sampathsl, Nov 5, 2008 IP