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 5 of 5
  1. #1
    [m]
    [m] is offline
    New Coder
    Join Date
    Nov 2002
    Location
    Virginia, USA
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    textbox clear and reset for IE working on NS

    this is a small java script I made that has the labeling text inside the text box, when u click on the text box it clears out the text that was in it so that u can type in it. if u didn't type anything and click out of it it returns back to the label. if u did type something in it stays. I just wrot it for IE cuz I didn't have NS, but now that I have NS I guess I'l make it so it works
    my hosting is down so here it is:
    PHP Code:
    <!doctype html public "-//w3c//dtd html 3.2//en">
    <!-== 
    Copyright ©2002mike.==- if you decide to modifiy this script I'd like to know how you changed it my mail is: [email]mike77800@hotmail.com[/email]>
    <html>
        <head>
            <title>loginSystem</title>
    <script>
        function inputMod(nameOfbox, valueOfbox){
            if(nameOfbox.value==valueOfbox){
                nameOfbox.value='';
            }else
            if(nameOfbox.value==""){
                nameOfbox.value=valueOfbox;
            }
            return(0);
        }    
    </script>
        </head>
        <body background="" bgcolor="#ffffff" text="#000000" link="#c0c0c0" vlink="#c0c0c0" alink="#c0c0c0">
            <center>Login information, input name and password<br><br>
                <input type="text" name="username" size="20" maxlength="16" value="Username" onfocus='
    inputMod(username"Username")' onblur='inputMod(username"Username")'><br>
                <input type="text" name="password" size="20" maxlength="16" value="Password" onfocus='
    inputMod(password"Password")' onblur='inputMod(password"Password")><br>
                <
    INPUT TYPE="submit" VALUE="Login"><br><br>
                <
    br>Copyright ©2002mike.
            </
    center>
        </
    body
    </
    html
    the function:
    inputMod(nameOfbox, "valueOfbox")
    says the name of the textbox and you can modifiy what it will say
    Last edited by [m]; 12-14-2002 at 06:27 PM.
    .:mike:.

    I'm a newbie

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    Spain
    Posts
    420
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if you decide to modifiy this script I'd like to know how you changed it
    That sounds like an invitation for me. ;) Well, my version has the following improvements:

    -Smaller code
    -Works in NS 4 (the old didn't)
    -Easier to use: it can be used easily with any input box without need to specify the help message every time. The script gets it from the .value in the first onfocus.


    PHP Code:
    <html>
    <
    head>
    <
    title>loginSystem</title>

    <
    script>
    function 
    inputMod(obj)
    {
     if (!
    obj.hlptextobj.hlptext=obj.value
     obj
    .value=(obj.hlptext==obj.value)?'':(obj.value=='')?obj.hlptext:obj.value
    }    
    </script>

        </head>
        <body background="" bgcolor="#ffffff" text="#000000" link="#c0c0c0" vlink="#c0c0c0" alink="#c0c0c0"><form>
            <center>Login information, input name and password<br><br>
                <input type="text" name="username" size="20" maxlength="16" value="Username" onfocus='inputMod(this)' onblur='inputMod(this)'><br>
                <input type="text" name="password" size="20" maxlength="16" value="Password" onfocus='inputMod(this)' onblur='inputMod(this)'><br>
                <INPUT TYPE="submit" VALUE="Login"><br><br>
                <br>Copyright ©2002, mike.
            </center></form>
        </body> 
    </html> 
    Don't resist to assimilation. Billions of Borgs can't be wrong!

  • #3
    [m]
    [m] is offline
    New Coder
    Join Date
    Nov 2002
    Location
    Virginia, USA
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ooow I like that thanx for the really cool inprovements. I have never seen it done like that!

    I am learning new things here every day woot!

    I never woulda thought of putting "this" in the..other thing
    Last edited by [m]; 12-15-2002 at 05:58 AM.
    .:mike:.

    I'm a newbie

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,047
    Thanks
    0
    Thanked 251 Times in 247 Posts
    this is much shorter:


    <input type="text" name="username" size="20" maxlength="16" value="Username" onfocus="this.value=''" onblur="if (this.value=='')this.value=this.defaultValue"><br>

    <input type="text" name="password" size="20" maxlength="16" value="Password" onfocus="this.value=''" onblur="if (this.value=='')this.value=this.defaultValue"><br>

  • #5
    Regular Coder
    Join Date
    Aug 2002
    Location
    Spain
    Posts
    420
    Thanks
    0
    Thanked 0 Times in 0 Posts
    wow! never seen .defaultvalue before. You really can learn new things everyday
    Don't resist to assimilation. Billions of Borgs can't be wrong!


  •  

    Posting Permissions

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