473,385 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to get the object that the client click?

At the old method, I place onFocus() event of all the tags like this:
<input id="input1" type="text" onFocus="func(this)">
to get the source (sender) of object.
But I think this is not a good design style for some case,
for example, I have fifty inputs in a HTML and half of it should run a
function when focus.

How to write this task better?

Jul 14 '06 #1
1 1443
How to write this task better?
>
Depends on what you want. If each input element has its own type of
handling, then the best option is what you describe, if its the same
handler you could use a loop:

// define the generic event handler
function myEventHandler() {
this.value = 'I have focus';
}

// get all input elements
inputs = document.getElementsByTagName("input");

// add the event handler to each of them.
for (i = 0; i < inputs.length; i++) {
inputs[i].onfocus = myEventHandler;
}

Something like that. You can even decide in the loop whether or not this
input element should have an event handler, and if so, which one.

Vincent
Jul 14 '06 #2

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

Similar topics

16
by: cwizard | last post by:
I'm calling on a function from within this form, and there are values set but every time it gets called I get slammed with a run time error... document.frmKitAmount.txtTotalKitValue is null or not...
9
by: Keith Rowe | last post by:
Hello, I am trying to reference a Shockwave Flash Object on a vb code behind page in an ASP.NET project and I receive the following error: Guid should contain 32 digits with 4 dashes...
3
by: Paul | last post by:
I have an Access 2000 database with a form that is giving me some major headaches. When you open the form, it displays all records and allows editing, but has AllowAdditions set to False so that...
0
by: Roman | last post by:
I'm trying to create the form which would allow data entry to the Client table, as well as modification and deletion of existing data rows. For some reason the DataGrid part of functionality stops...
11
by: John Boghossian | last post by:
I know this isnīt spot on for this group, but the problem relates to an asp.net project i am working on. I am trying to develop an windows forms control to be used in IE in an intranet solution....
7
by: Quentin Huo | last post by:
Hi: I created a web-form user control. And in client-site, there is a link which will create a Input element object when it is clicked. <script language=javascript> ....... var nameInput =...
4
by: mabuHB | last post by:
Hi, I am writing a small app to check for the existence of files on remote workstations. GUI is great, but when I click to check the workstations, the following error is displayed. The point of...
6
by: rlcavebmg | last post by:
I am new to Web Services and .NET development, and I have a question. I am writing a service that will create a bitmap image and return it to the client. First, I wrote a method that looked like...
5
by: Joseph Geretz | last post by:
Here's my first attempt at DIME (code below signature). I'ts basically straight out of Microsoft's online sample: For some reason, the statement respContext.Attachments.Add(dimeAttach); ...
1
geo039
by: geo039 | last post by:
Okay I have an application, which is to demonstrate the use of a created class. I have a previous and next button which cycles through the array. However I need the user to be able to create a new...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.