473,834 Members | 2,319 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 4626

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
2557
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
2304
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
3293
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 the "Searching..." page and not the table that I want. below is the code i have so far....Thanks...
60
8040
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 added by the server. Taking the form:- ` Content-Disposition: attachment; filename=filename.ext `
4
2647
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 object, I double checked to make sure that there's only one instance of id = "servif" and I never use...
3
2374
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 this is always returning null. The <t:inputText > is present with in a <t:div>. Can you please...
7
3362
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 with this error - please provide other feedback about my code, since I want to write a solid...
6
4968
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
3142
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 & Chrome. Only the form button, document.myname.submit(); and document.forms.submit(); worked. Take a...
0
9796
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10786
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10544
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10214
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9326
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7754
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5790
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4425
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
3
3079
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.