To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > Misc Help > ClientSide Technologies

ClientSide Technologies Discuss HTML/CSS/Javascript, and any other client-side technologies, here.

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-17-2006, 01:54 AM   #1
NZ_Kiwis
Senior Member
 
Join Date: Apr 2005
Posts: 699
textbox

this is a blank textbox, some websites have a thing inside like "username" and when you click in there is goes away... how can i add this anyone know??


PHP Code:
<input name='username' size='10' style='font-family: Tahoma; border-style: solid; border-width: 1px; font-size:8pt'>
PS: i know this is not PHP but it's the only website i use a forum on and everyone is so good at helping ;-)
NZ_Kiwis is offline   Reply With Quote
Old 03-17-2006, 02:04 AM   #2
laserlight
PHP Witch
 
laserlight's Avatar
 
Join Date: Apr 2003
Location: Singapore
Posts: 12,388
tsk tsk, but anyway, add the attribute:
onfocus="this.value=''"

That reminds me, we actually have a ClientSide Technologies forum that you should have used.
__________________
Use Bazaar for your version control system
Read the PHP Spellbook
Learn How To Ask Questions The Smart Way
laserlight is offline   Reply With Quote
Old 03-17-2006, 02:16 AM   #3
NZ_Kiwis
Senior Member
 
Join Date: Apr 2005
Posts: 699
that only works when you click in the box. i want to show when the page loads :-)
NZ_Kiwis is offline   Reply With Quote
Old 03-17-2006, 02:23 AM   #4
Weedpacket
Custom User Title™
 
Weedpacket's Avatar
 
Join Date: Aug 2002
Location: Rapid Offensive Unit "Foreign Object Damage"
Posts: 19,126
Quote:
Originally Posted by NZ_Kiwis
PS: i know this is not PHP but it's the only website i use a forum on and everyone is so good at helping ;-)
Which is one reason why there is now a more appropriate forum for these sorts of questions.

Anyway;
Quote:
Originally Posted by NZ_Kiwis
that only works when you click in the box. i want to show when the page loads :-)
onLoad="" then.
__________________
On two occasions I have been asked [by Members of Parliament], "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.

Last edited by Weedpacket; 03-17-2006 at 02:28 AM.
Weedpacket is offline   Reply With Quote
Old 03-17-2006, 08:13 AM   #5
dream.scape
Senior Member
 
dream.scape's Avatar
 
Join Date: Jan 2006
Posts: 204
Quote:
Originally Posted by NZ_Kiwis
that only works when you click in the box. i want to show when the page loads :-)
no you don't put the value you want in there; that is used to clear it out. You put the default value in the value="" attribute.

HTML Code:
<input name="search" value="search for..." onfocus="this.value='';" />

Last edited by dream.scape; 03-17-2006 at 08:15 AM.
dream.scape is offline   Reply With Quote
Old 03-17-2006, 11:35 AM   #6
Merve
black sheep with red wool
 
Merve's Avatar
 
Join Date: Jul 2003
Location: North of the 49th parallel
Posts: 2,579
Maybe I'm wrong, but I see an issue with simply using onfocus. If the user types a value in the textbox, clicks somewhere else, then clicks back in the textbox, whatever value he or she had typed in the textbox would be erased. You would need some sort of check to make sure it was only the first focus.

How about:
Code:
<script>
var isFocus = 1;

function eraseText () {
     if(isFocus == 1) {
          window.document.blahform.blahtext.value = "";
          var isFocus = 0;
     }
}
</script>
HTML Code:
<form name="blahform" id="blahform" action="#">
<input type="text" name="blahtext" id="blahtext" value="Type Here!" onfocus="eraseText();" />
</form>
I apologize for my malformed JavaScript and the fact that I may have made a few mistakes in the code, but that's the general idea of what you should have.
__________________
"A proof is a proof. What kind of a proof? It's a proof. A proof is a proof. And when you have a good proof, it's because it's proven." -- Jean Chrétien

The Three C's
Merve is offline   Reply With Quote
Old 03-17-2006, 01:21 PM   #7
NZ_Kiwis
Senior Member
 
Join Date: Apr 2005
Posts: 699
so would this not work as well then??

onfocus=this.type='password'
NZ_Kiwis is offline   Reply With Quote
Old 03-17-2006, 02:16 PM   #8
JPnyc
Administrator
 
Join Date: Jan 2005
Posts: 963
If you put proper quotes around it, it would
__________________
PHP builder Online Community Manager

JPnyc is offline   Reply With Quote
Old 03-17-2006, 02:25 PM   #9
NZ_Kiwis
Senior Member
 
Join Date: Apr 2005
Posts: 699
such as?
NZ_Kiwis is offline   Reply With Quote
Old 03-17-2006, 02:55 PM   #10
JPnyc
Administrator
 
Join Date: Jan 2005
Posts: 963
onfocus="this.type='password';"
__________________
PHP builder Online Community Manager

JPnyc is offline   Reply With Quote
Old 03-17-2006, 05:25 PM   #11
Merve
black sheep with red wool
 
Merve's Avatar
 
Join Date: Jul 2003
Location: North of the 49th parallel
Posts: 2,579
Quote:
Originally Posted by NZ_Kiwis
so would this not work as well then??

onfocus=this.type='password'
In that case, only the code that JPnyc provided is necessary. That's because no matter how many times the input box is focused, you want it to change to a password input the first time, and remain a password input on subsequent focuses.

The problem with only using onfocus with the previous case (username) is that you don't want their username to disappear if they unfocus the textbox and them refocus it.
__________________
"A proof is a proof. What kind of a proof? It's a proof. A proof is a proof. And when you have a good proof, it's because it's proven." -- Jean Chrétien

The Three C's
Merve is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
Forum Jump


All times are GMT -4. The time now is 12:34 AM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.