473,569 Members | 2,572 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error: document.getEle mentById("ff") has no properties

Hi

I want a form field to be selected when the page loads.

But I get the error message
Error: document.getEle mentById("ff") has no properties

any ideas what I am doing wrong?

code below
cheers Dave
<script type="text/javascript">
function setfocus()
{
document.getEle mentById('ff'). focus();
}
window.onload = setfocus();
</script

<form>
<input type="text" id="ff" >
</form>

Nov 27 '06 #1
6 4582

li********@yaho o.com.au wrote:
Hi

I want a form field to be selected when the page loads.

But I get the error message
Error: document.getEle mentById("ff") has no properties

any ideas what I am doing wrong?
Passing the result of setfocus(), rather than a reference (see below).
>
code below
cheers Dave
<script type="text/javascript">
function setfocus()
{
document.getEle mentById('ff'). focus();
Nothing to do with your problem, but it is considered better to use the
forms collection rather than getElementById - it is more widely
supported and faster. You should also test for the focus method before
trying to call it:

var el = document.forms[0].elements['ff'];
if (el.focus) el.focus();

}
window.onload = setfocus();
Your issue is here:

window.onload = setfocus; // Remove ()

[...]

--
Rob

Nov 27 '06 #2
Your issue is here:
>
window.onload = setfocus; // Remove ()

thanks for the answer, my brain was starting to melt
Dave

Nov 27 '06 #3
li********@yaho o.com.au wrote:
I want a form field to be selected when the page loads.
any ideas what I am doing wrong?
window.onload = setfocus();
should be:

window.onload = setfocus;

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Nov 27 '06 #4
solution 1 window.onload = setfocus;
solution 2
function window.onload()
{
document.getEle mentById("ff"). focus();
}
Matt Kruse wrote:
li********@yaho o.com.au wrote:
I want a form field to be selected when the page loads.
any ideas what I am doing wrong?
window.onload = setfocus();

should be:

window.onload = setfocus;

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Nov 27 '06 #5
ih*********@gma il.com wrote:
solution 1 window.onload = setfocus;
solution 2
function window.onload()
{
document.getEle mentById("ff"). focus();
}
Not a solution really as a property accessor in the position where an
Identifier is expected in a function declaration is a syntax error
(which is tolerated in IE but won't pass many other browsers without
complaint).

Richard.

Nov 27 '06 #6
Awsome! This thread helped me! Thanks guys!

Dec 5 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
2514
by: David. E. Goble | last post by:
Hi All; I have a few of these; sigsImages="sigs/finished1.jpg" sigsImages="sigs/foghorn.jpg" lower I have;
1
2287
by: dasayu | last post by:
Hi, I have a custom object called gridWidget. I am consistantly getting an error in FireFox when I click on an href, which calls a function defined on the object. The generated link looks similar to: javascript:gridWidget.editColumn(3, 3, 'PDDSectionForm', 'pdd_link', ..) The above works fine in IE.
3
3274
by: Aaron | last post by:
I'm trying to parse a table on a webpage to pull down some data I need. The page is based off of information entered into a form. when you submit the data from the form it displays a "Searching..." page then, refreshes and displays the table I want. I have code that grabs data from the page using cURL but when I look at the data it contains...
60
7914
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type? ----------------------------------------------------------------------- It is not possible with client-side JavaScript. Some browsers accept the Content-Disposition header, but this must be...
4
2618
by: dr1ft3r | last post by:
Hey guys, I'm building a site for a landscaping business down the street and can't seem to get part of the code functioning correctly. The code fails on line 68 where I make a reference to an iframe's src property. Being that IE does not follow standard and considers an id, name, etc as a qualifying identifier for the document.getElementById...
3
2355
by: karprix | last post by:
Hi, I am working on a webapplication,( with Ajax & JSF) where I want to retrieve the value present in a <t:inputText id="starttimeScheduler" value="#{scheduledJobCreateEdit.startTimeDate}" style="width:165px; margin-left: 25px;" forceId="true" tabindex="112"> by using document.getElementById("starttimeScheduler") in my javascript function. but...
7
3343
by: dennis.sprengers | last post by:
I am trying to write an editor object, which adds some functionality and a toolbar to every textarea with a "form-textarea" class. Both FF and IE generate an error in line 20 (container.appendChild(this.toolbar);) saying "Node cannot be inserted at the specified point in the hierarchy" code: "3" I have two questions: - who would help me...
6
4948
by: cleary1981 | last post by:
I have adapted code from http://dunnbypaul.net/js_mouse/ I want to use a button to create new draggable divs but i keep getting error "is null or not an object" heres the code <html> <head> <title>Drag and drop module</title> <style type="text/css"> #canvas {
2
3109
by: ChrisLA | last post by:
Hi; I've seen lots of discussion & disagreement on this issue, so any good explanation would be appreciated. Some people seem to think that "document.GetElementByID("MyName").submit(); should and does work. I and others have experienced that it should & doesn't work. I'll give you a little file that I tested with IE 6, FF 3, Opera &...
0
7711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7938
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8145
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7694
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6317
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3679
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2128
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.