Digital Point Forums
westernunion

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

Reply
 
Thread Tools
  #1  
Old Jun 13th 2005, 4:00 am
misohoni misohoni is offline
of the Nightfall
Recent Blog: Using Go Daddy
 
Join Date: Mar 2004
Location: Hong Kong
Posts: 1,226
misohoni is on a distinguished road
How to type in a Form Field without clicking it - i.e like Google/Yahoo?

This may be an easy one and I used to be able to do this in old versions of DW, but how to make a field open (i.e. you can type in it straight away) without clicking on it first.

Examples - the search boxes in Yahoo/Google...you don't need to click on them before you type your search.

Thanks
Reply With Quote
  #2  
Old Jun 13th 2005, 4:27 am
tresman tresman is offline
Champion of the Naaru
 
Join Date: Dec 2004
Posts: 235
tresman will become famous soon enough
javascript

It's javascript, did you looked at google code?

you can do that:

Code:
<body onload="myfunction()">
now, betweeen the <head> and the </head> you have to add:

Code:
<script type="text/javascript">
<!--
function myfunction() {
this.focus()
};
// -->
</script>
This should work, but if not you reply here or do some test. I am not a javascript guru (I'm reallyyyyy far waya from) but this is basically the idea.
Reply With Quote
  #3  
Old Jun 13th 2005, 8:26 am
misohoni misohoni is offline
of the Nightfall
Recent Blog: Using Go Daddy
 
Join Date: Mar 2004
Location: Hong Kong
Posts: 1,226
misohoni is on a distinguished road
Ah I thought it was something I needed to add in the <input form part> thanks, I'll test it
Reply With Quote
  #4  
Old Jun 22nd 2005, 4:42 am
cagintranet's Avatar
cagintranet cagintranet is offline
Hand of A'dal
Recent Blog: Coming Soon
 
Join Date: Mar 2005
Location: Pittsburgh, PA
Posts: 327
cagintranet is on a distinguished road
Heres what i use:
add this onload statement to your <body> tag.
php Code:
<body OnLoad="document.requestform.aname.focus();">
syntax is document.[formname].[fieldname that needs the focus].focus()


below is the input field that will be recieving the focus... see how the name of it is "aname" - same as in the onload statement?
php Code:
<input type="text" name="aname" value="">
hope this helps
__________________
- Chris

ADSENSE ADVICE | Pittsburgh Directory |
Reply With Quote
  #5  
Old Jun 22nd 2005, 7:52 am
misohoni misohoni is offline
of the Nightfall
Recent Blog: Using Go Daddy
 
Join Date: Mar 2004
Location: Hong Kong
Posts: 1,226
misohoni is on a distinguished road
thanks but didn't work for me.
Reply With Quote
  #6  
Old Jun 22nd 2005, 8:24 am
tresman tresman is offline
Champion of the Naaru
 
Join Date: Dec 2004
Posts: 235
tresman will become famous soon enough
Well Mishoni,

I thought you had already solved this problem. But look like not.

I think it didn't work cause you haven't read carefully what he said.

Please note this

Quote:
syntax is document.[formname].[fieldname that needs the focus].focus()
And note now the [formname].

Give your form a name and it will work.

But if you do not want to think, find te code below

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

  <head>
    <title>
    </title>
  </head>
  <body onload="document.myform.myinput.focus()">
  
  <form name="myform">
  <input name="myinput" type="text" />
  <input type="button" value="GO!" />
  </form>
  
  </body>
  
</html>
Is that easy. Look at "myfrom" and look at "myinput". Look too at the onload statement. It's that easy man.

cagintranet in fact solved your problem already.
Reply With Quote
  #7  
Old Jun 22nd 2005, 9:34 am
misohoni misohoni is offline
of the Nightfall
Recent Blog: Using Go Daddy
 
Join Date: Mar 2004
Location: Hong Kong
Posts: 1,226
misohoni is on a distinguished road
Err thanks for the beginneers run thru, your rcode didn't work for me though - I've got multi-layered dynamic tabs on my site same as Google/Yahoo and it doesn't pick it up. Here's the code I've been messing with but I don't think there's a solution. No Cagintranet's code gives JS errors...

<script>
<!--
function selector(){document.schina.q.focus();}
d=document;
// -->
</script>
</head>
<body onLoad=selector()>
Reply With Quote
  #8  
Old Jun 22nd 2005, 10:56 am
tresman tresman is offline
Champion of the Naaru
 
Join Date: Dec 2004
Posts: 235
tresman will become famous soon enough
can you please post the site so I can have look. Or pls pm.
Reply With Quote
  #9  
Old Jun 23rd 2005, 12:35 am
misohoni misohoni is offline
of the Nightfall
Recent Blog: Using Go Daddy
 
Join Date: Mar 2004
Location: Hong Kong
Posts: 1,226
misohoni is on a distinguished road
Thanks for the offer, I've spent a couple of hours on it and realised it's not worth it at this moment...is ok thanks for the help though.
Reply With Quote
  #10  
Old Jul 14th 2005, 9:23 pm
webnp05 webnp05 is offline
Peon
 
Join Date: Jul 2005
Posts: 2
webnp05 is on a distinguished road
focus not in Safari Mac

document.form.fieldname.focus() does not seem to work on Safari when i test it. Is anyone else having this trouble? Anyone can provide a solution please?
Reply With Quote
  #11  
Old Jul 15th 2005, 5:58 am
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
document.form.fieldname.focus() does not seem to work on Safari when i test it. Is anyone else having this trouble? Anyone can provide a solution please?
Try this:

<body onload="document.forms.n1.n3.focus()">
<form name="n1">
<input name="n2"><input name="n3">
</form>
</body>

or this:

<body onload="document.getElemenetById("id3").focus()">
<form>
<input name="n2"><input name="n3" id="id3">
</form>
</body>

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
Preparing for Google vs. Yahoo Adsense type products. d360 Publisher Network 10 Apr 29th 2005 8:23 am
Does Yahoo use some form of sandboxing? hmilesjr Yahoo 12 Apr 25th 2005 12:22 am
How to add a background colour to an Input type in a form misohoni CSS 2 Nov 7th 2004 9:10 pm
How To Define Width Of Field In Form? digitalpoint CSS 8 Oct 9th 2004 1:43 am
Payment Type Field directusnet Optigold ISP 1 Sep 21st 2004 7:46 am


All times are GMT -8. The time now is 10:47 pm.