Web Hosting Deals Holiday Logo Design Webcam Chat Website Header Templates Register domain Search Engine Optimisation Web Hosting
Go Back   Talk Mania Forum > Tutorials > PHP / Perl / Java / JavaScript / CGI Tutorials

PHP / Perl / Java / JavaScript / CGI Tutorials PHP / Perl / Java / JavaScript / CGI Tutorials Please do not use this Forum to advertise your site or to link to tutorials.

 Image
Buy Sell Downloads

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-11-2007, 06:39 AM
Junior Member
 
Join Date: Nov 2006
Posts: 23
FTH8er is on a distinguished road
Clear Text Box

Before I start this nice and simple (but effective code) I would like to

Note: That there is not much to comment on here, as it is kinda self explanatory (I will try to comment it best I can at the end), and you can not (as I know of) use this in like a textarea but only an are such like a Login Box.

And We Are Off:
Code:
Username: <input size="15" name="login" class="forminputb" onclick="if (this.value == 'Username') { this.value = ''; }" onfocus="if (this.value == 'Username') { this.value = ''; }" onblur="if (this.value == '') { this.value = 'Username'; }" type="username" value="Username" /><br />
Obviously, this would be part of a login script or register script.
To start off We have the word Username: Which says what you input into that box. Then We follow up by making the <input> code which makes the text box to put the info.

Next we define how long we want it (size="15") so its 15 pixel long. Then we just give it a name. And then we give it a class to edit it in our css if wanted.

Now comes some more advanced stuff which I may not be able to explain to offel well but Ill try. So we start with this.
Code:
onclick="if (this.value == 'Username') { this.value = ''; }"
This is saying that when you dont have your mouse (cursor) in the input box, it will say Username, and when your mouse (cursor) is in the input box, it will go to be blank so you are able to type in your info.

Next we have This:
Code:
onfocus="if (this.value == 'Username') { this.value = ''; }"
This is basically doing the same thing only you are able to click out of it and your info you have put in it will stay there instead of reseting itself.

And now we have This:
Code:
onblur="if (this.value == '') { this.value = 'Username'; }"
This is saying is when you have clicked in the box, and typed nothing, then clicked out of it, it will return back to the word Username.

And now is just some of the easier stuff to explain again:
Code:
type="username" value="Username" />
All this is doing (type="username") is defining what type of text to use, such as if you have a password one it would put in astrics (*'s) or some other character, and the other one (value="Username") is just saying what to start off with in the box.

I hope I did this well enough for you to at least understand a little bit. If I didnt you could always just copy and paste it lol.

(P.S. = In the
Code:
onclick="if (this.value == 'Username') { this.value = ''; }"
code, after this.value = it is not a quotation but 2 single quotes, so as not to confuse neone.)

Reply With Quote
  #2 (permalink)  
Old 05-15-2007, 11:03 PM
Junior Member
 
Join Date: May 2007
Posts: 21
straitlaced is on a distinguished road
How smart are you

How smart are you
Reply With Quote
  #3 (permalink)  
Old 05-17-2007, 06:50 AM
Junior Member
 
Join Date: Nov 2006
Posts: 23
FTH8er is on a distinguished road
not very why? I might be missing some obvious things, but i did as best I could on explaining something I really dont know of what all it means. I did my best, in either which case, just look at it and learn it. Its not to difficult.
Reply With Quote
  #4 (permalink)  
Old 05-18-2007, 09:37 PM
Junior Member
 
Join Date: May 2007
Posts: 20
zezikaro is on a distinguished road
I'm not sure if i've done this right o.O

Maybe you could give an example page / screenshot >.<
Reply With Quote
  #5 (permalink)  
Old 05-22-2007, 01:37 AM
jakeyuan110's Avatar
Junior Member
 
Join Date: Mar 2007
Posts: 21
jakeyuan110 is on a distinguished road
you are smart
haha
__________________
http://www.myspace.com/jakeyuan
Reply With Quote
  #6 (permalink)  
Old 05-28-2007, 10:13 PM
Junior Member
 
Join Date: Nov 2006
Posts: 23
FTH8er is on a distinguished road
Ok here is a working example of it now. Sorry it took so long, have been busy.

New Website (Still Under Construction

Look In The Users Box, Both The Username And Password One Works.

P.S.: Wthis Site Is For A Friend. lol
Reply With Quote
  #7 (permalink)  
Old 05-29-2007, 08:56 AM
Senior Member
 
Join Date: May 2007
Posts: 181
Blog Entries: 1
skyfe is on a distinguished road
Pretty nice but when you click on the username, it clears he, but if I click then directy after I clicked on the username, on the password field, then it only clears the password field and the username field gets filled again
edit: nvm, I see that's also the meaning

Last edited by skyfe; 05-29-2007 at 08:58 AM.
Reply With Quote
  #8 (permalink)  
Old 05-30-2007, 09:21 AM
Junior Member
 
Join Date: Nov 2006
Posts: 23
FTH8er is on a distinguished road
Thumbs up

ok you had me worried there, but ya thats the point, as long as what you have typed stays in the input field, and when you tab etc... It should be working right, if not let me know on here, and post your code to see If I can help you.

And Why Do People keep saying Im Smart lol, Its kinda basic Javascript. O well i dont mind.
Reply With Quote
  #9 (permalink)  
Old 06-01-2007, 06:48 PM
Junior Member
 
Join Date: May 2007
Posts: 20
emFOUR is on a distinguished road
:)

Smart ))
Reply With Quote
  #10 (permalink)  
Old 06-07-2007, 09:27 PM
Junior Member
 
Join Date: Jun 2007
Posts: 23
Evan is on a distinguished road
Thanks, stuff like this is pretty straight forward

Good job!

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT +2. The time now is 11:42 PM.


Fake ID

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC8
Forums Copyright © Talk-Mania.com