473,396 Members | 1,797 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,396 software developers and data experts.

javascript attachEvent

How to pass argument uisng attachEvent

ex:

Expand|Select|Wrap|Line Numbers
  1. var CellAdd2 = document.createElement("td"); 
  2. CellAdd2.width="220"
  3. var Period = document.createElement("INPUT")
  4. Period.setAttribute("name","TxtPeriod"+RowCount)
  5. Period.setAttribute("id","TxtPeriod"+RowCount)
  6. Period.setAttribute("runat","server")
  7. Period.attachEvent("onkeyup",fnEscalationPeriod(this)) //-->in this line  i am getting an error
  8.  
Aug 3 '07 #1
1 1625
gits
5,390 Expert Mod 4TB
hi ...

with:

Expand|Select|Wrap|Line Numbers
  1. Period.attachEvent("onkeyup",fnEscalationPeriod(this));
  2.  
you make a functioncall of fnEscalationPeriod immediately ... so you get the error ... you want to assign the function to the obj called Period ... ok? so you have to use:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.     function fnEscalationPeriod(obj) {
  3.         alert(obj.id);
  4.     }
  5.  
  6.     function add_event() {
  7.         var keyup_handler = function(e) {
  8.             var obj = e.srcElement;
  9.             fnEscalationPeriod(obj);
  10.         };
  11.  
  12.         // and later on you have to use
  13.         document.getElementById('test')
  14.             .attachEvent('onkeyup', keyup_handler);
  15.     }
  16. </script>
  17.  
  18. <body onload="add_event();">
  19.     <input id="test" type="text"/>
  20. </body>
  21.  
kind regards

ps: note - that is IE-specific ... other browsers use addEventListener instead
Aug 3 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: sylcheung | last post by:
Hi, How can I be notified when the document load is complet in JavaScript? I am referring to the whold document load is complete, mean all images/external files/frame/iframes have been loaded. ...
2
by: yawnmoth | last post by:
Say I had <select id="something" name="something" onchange="demo(this.value)"> but didn't want to define the onchange event handler in the select tag, itself. ie. I wanted to attach it, latter,...
7
by: Coder | last post by:
Hi I have the following code in java script, it is not giving proper output in FIREFOX but running fine in IE... can anybody help me out to make this run in FIREFOX . <script...
5
by: pwsmeister | last post by:
I'm fairly new to javascript, my take on the below code is that it is creating a array called event and populating it with 3 functions( add, remove and DOMit). Is my take on this code correct? ...
6
by: Damo | last post by:
Hi I'm new to javascript and i'm trying to create a simple form that: has a text field and a button when the page is initially loaded the text field is not visible. Pressing the button is...
1
by: arrival123 | last post by:
I know its an odd question, but I need some help converting javascript to vbscript. I understand from my readings that its going backwards, but my professor requires it for one of my class. Here is...
5
Frinavale
by: Frinavale | last post by:
I have a slight problem with a Tab Control that I've developed for an application. Once sent to the browser it runs via JavaScript. The JavaScript is dynamically generated by my .NET code. ...
9
by: -Lost | last post by:
http://blogs.msdn.com/ie/archive/2007/12/19/internet-explorer-8-and- acid2-a-milestone.aspx Oh my! A somewhat standards compliant Internet Explorer? What about JavaScript? Not that it proves...
2
by: davidson1 | last post by:
Hai friends..for menu to use in my website..i found in one website....pl look below website.... http://www.dynamicdrive.com/dynamicindex1/omnislide/index.htm i downloaded 2 files.... ...
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
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: 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...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.