Digital Point Forums
Wester Union

Go Back   Digital Point Forums > Design & Development > Programming > JavaScript
Google Analytics
Log In to view
your analytics

Reply
 
Thread Tools
  #1  
Old May 16th 2004, 12:03 am
jarvi jarvi is offline
Berserker
 
Join Date: Mar 2004
Location: Melbourne Australia
Posts: 127
jarvi is on a distinguished road
Start the cursor in the search box

I have a very basic php page that really just displays the standard menu items for the site plus a search box using a form and submit button. How do I get it so that the cursor is in the search box and the user can just start typing, rather than having to click in the box first?

Google does it if you can't understand what I am saying.
__________________
James

Buy Books Online | Casino Affiliate Programs | |
Reply With Quote
  #2  
Old May 16th 2004, 3:47 am
nlopes nlopes is offline
Champion of the Naaru
 
Join Date: Mar 2004
Location: Portugal
Posts: 103
nlopes is on a distinguished road
This is just a simple javascript code.

In <head> add this:
<script>
<!--
function focus(){document.FORM_NAME.INPUT_NAME.focus();}
// -->
</script>

And then in <body>:
<body onLoad=focus()>
Reply With Quote
  #3  
Old May 17th 2004, 2:02 am
jarvi jarvi is offline
Berserker
 
Join Date: Mar 2004
Location: Melbourne Australia
Posts: 127
jarvi is on a distinguished road
Thanks, mate. Knew it wold be something simple.
__________________
James

Buy Books Online | Casino Affiliate Programs | |
Reply With Quote
  #4  
Old Jul 14th 2005, 9:18 pm
webnp05 webnp05 is offline
Peon
 
Join Date: Jul 2005
Posts: 2
webnp05 is on a distinguished road
Browser compatibility

Does this work with Safari on a mac?
Reply With Quote
  #5  
Old Jul 15th 2005, 9:43 pm
J.D. J.D. is offline
of the Nightfall
 
Join Date: Nov 2004
Posts: 1,198
J.D. has a spectacular aura aboutJ.D. has a spectacular aura about
Quote:
Originally Posted by webnp05
Does this work with Safari on a mac?
This syntax is not standard - only elements in HTML collections can be accessed using this notation (i.e. using id's as JS identifiers). This syntax will work in all DOM-compliant browsers:

document.getElementById("input-id").focus();

input-id must be the value of the ID attribute of the input element, not name.

J.D.
Reply With Quote
Reply

Bookmarks

Thread Tools

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Download box pops up for results.php when I try to search beckmann All Other Tools 4 Feb 8th 2009 2:52 am
Google search quits on OS X.2 w/WebSTAR5.3 mduke All Other Tools 7 Nov 11th 2008 5:00 pm
Labs.google.com - New Tool Added just Hours AG0 ! ! Google 11 Sep 26th 2004 3:44 pm
New search start up funded by State of KS anthonycea All Other Search Engines 3 Jun 17th 2004 3:22 pm
Yet another "My search doesn't work on my site" (google/api related) fugpup All Other Tools 4 May 5th 2004 8:34 am


All times are GMT -8. The time now is 9:26 am.