Time:
Scotland: Fri, 10:00 pm Rhode Island: Fri, 5:00 pm Florida: Fri, 5:00 pm New Mexico: Fri, 3:00 pm California: Fri, 2:00 pm
Buy this Ad Space. 180px wide. Please get in touch with KH@ if you are interested and make an offer.
US$10 per year - Save $100s! The Fabulously Unfair WebX Auction Bar. For Ebay etc. Ro-Sham-Bo the opposition. Laugh like Eric Cartman when you win! CLICK HERE NOW!More information and sign-up.
WebXpertz Hosting. Custom fit from $5pm. PHP/MySQL You'll save money, we'll save money. Seems fair to me. Interested? If so Please PM me here and tell me what you need. Thanks!
|
For continued disscussion on this topic : Highlighting Text in a Text Box
Jason Hill 10-05-2001, 01:56 AM Hello,
I forgot how to make my default text in my text box be highlighted by default. Cann you remind me please.
IE:
<INPUT TYPE="text" name="keytxt" value="Type Search Here!" style="width:150">
I would like my value, "Type Search Here!" to be highlighted for the user by default initially.
Thanks,
Jason
Kool Dude 10-05-2001, 06:22 AM Hmm.. not sure I remember right well how but maybe..
<INPUT TYPE="text" name="keytxt" value="Type Search Here!" style="width:150; select:all">
:bambooz:
voicebox 10-05-2001, 02:00 PM Hi Jason,
Put this attribute in your body tag:onload="document.formName.keytxt.focus(); document.formName.keytxt.select()"of course replacing formName with the name of the form.
Jason Hill 10-05-2001, 08:32 PM Thank you Kool Dude,
I tried:
<INPUT TYPE="text" name="keytxt" value="Type Search Here!" style="width:150; select:all">
but, it won't work. And the onload one works, but I have many different txt boxes, cause I'm using ColdFusion as well with multiple IF statements, so I don't know what the name of the text box will be according to the category selected.
Any other suggestions? If you can look up the <select:all> attribute, it would be greatly appreciatyed.
Thanks,
Jason
Jason Hill 10-05-2001, 09:14 PM Thank you, I'm almost there.
onload="document.forms[0].elements[1].select();"
will work, however, depending on the selection of the user to search by KEYWORD or COMPANY, the page returns with a text box or a select box. If it comes back with a text box, the onload() event works great, HOWEVER, if the user selects to search by company, and it comes back with a select box, the select() method doesnt apply to the select list and gives me an error.
ALSO, once the user submits the search, the resulting page does'nt have a second feld . SO the statement including, elements[1] doesn't apply either.
THEREFORE, I'm thinking to try something like this:
OnLoad="javascript: if (document.forms[0].elements[1].value is TRUE AND if (document.forms[0].elements[1].name=='keytxt' || document.forms[0].elements[1].name=='prodtxt') document.forms[0].elements[1].select();"
But, I need some of your help with the code.
Thanks again,
Jason
voicebox 10-05-2001, 09:53 PM Hi Jason,
The fastest way to do what you want (and which will be compatible if one day browsers do have a select method on select boxes for some reason) is to check for the method within the object before you call it, for example:if (document.forms[0].elements[1].select) document.forms[0].elements[1].select();
Jason Hill 10-05-2001, 11:05 PM Thank you Mr. Voice Box,
You're code works great:
OnLoad="javascript: if (document.forms[0].elements[1].select()) document.forms[0].elements[1].select();"
HOWEVER, once the search is submited, the resulting [age only has one element, the serch selection list with keyword, company, product.
SO I keep getting the error:
"document.forms[0].elements[1]" is undefined, or null.
SO, I have to validate that it exists first of all in my javascript statement.
Thanks,
Jason
Jason Hill 10-05-2001, 11:21 PM I'm soooooo close. This is what I'm using:
OnLoad="javascript: if ((document.forms[0].elements[1]) && (document.forms[0].elements[1].select())) {document.forms[0].elements[1].select()};"
HOWEVER, if the user wants to search by company, using a select list instead of a text box, I get the following error:
Object does'nt support this property or method
...because it is a select list.
SO what prop or meth does it support??
Thanks,
Jason
voicebox 10-06-2001, 05:14 PM Hi Jason,
If you have another look at my post there are no () brackets after the select within the if statement (this is because I'm just checking to see if the function exists, not trying to call it). So the code you want would look like this:if ((document.forms[0].elements[1]) && (document.forms[0].elements[1].select)) {document.forms[0].elements[1].select()}
Jason Hill 10-08-2001, 08:20 PM Thank You Mr. VoiceBaxo,
It seems to be working now. Thanks for your help.
Jason
vBulletin® v3.6.4, Copyright ©2000-2008, Jelsoft Enterprises Ltd.
|