473,779 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting events dynamically!

18 New Member
hi everybody,
i have a problem.. i get some html through ajax from a sevlet. before displaying it on screen i dynamically create a DIV element using createElement. I specify the CSS for this DIV as follows:
Expand|Select|Wrap|Line Numbers
  1. subMenu = document.createElement('<div>');
  2. subMenu.id = "subArea";
  3.  
I tried subMenu.onmouse over = fun; But its' not working!

Now I want to give some Event to this div.. how do i do it?
Thanks in advance.
-- Abdel Raoof Olakara
Jan 23 '07 #1
3 1528
acoder
16,027 Recognized Expert Moderator MVP
It should work. I assume you have already defined fun as a function, but you also need to append this div to the document, e.g. to the document body:
Expand|Select|Wrap|Line Numbers
  1. document.body.appendChild(subMenu);
Jan 23 '07 #2
olakara
18 New Member
It should work. I assume you have already defined fun as a function, but you also need to append this div to the document, e.g. to the document body:
Expand|Select|Wrap|Line Numbers
  1. document.body.appendChild(subMenu);
I have added the subMenu as you said to the document.. but still the function fun() won't work! If you use Firebug you will see that it is not attached to the DIV or any element that i am trying to put the event to.
Thanks in advance
-- Abdel Olakara
Jan 25 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
For it to work, you need to add some content to the div, e.g.
Expand|Select|Wrap|Line Numbers
  1. subMenu = document.createElement('<div>');
  2. subMenu.id = "subArea";
  3. subMenu.innerHTML = "subArea";
  4. subMenu.onmouseover = fun;
  5. document.body.appendChild(subMenu);
Jan 25 '07 #4

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

Similar topics

6
3334
by: Thomas | last post by:
Hi, I'm having a problem with the dynamically created inputfields in Internet Explorer. The situation is the following: - I have a dynamically created table with a textbox in each Cell. - It is possible to Add and Delete rows - Some cells have special attributes (readonly and events) Here's a snippet of the code:
4
2561
by: blue | last post by:
I have a drop-down list, a radio button list and a submit button. I'm adding these controls to a table and I'm adding the table to a Placeholder. I'm adding it to the Placeholder because I don't know exactly where the table will be located on the page until runtime. Before the form control table is added to the Placeholder, I'm adding a whole bunch of tables to the Placeholder. This is a flowchart program and I have multiple action boxes...
1
7588
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a dropdown in UC1 _________________________ 1) MainPage_Load 2) User Control_1 Load
1
8167
by: Earl Teigrob | last post by:
PROBLEM: When a user control is loaded into a PlaceHolder control more than once, the events do not fire on the first click of a control on the dynamically loaded user control. In other words, the first time the control is dynamically loaded, everything works fine. After that, if the control is loaded again from the page button event handler, the user controls events fail to fire on the first click NOTE: I (believe I) am rebuilding all...
7
1312
by: bredal Jensen | last post by:
Hello, I have populated a web form with dynamically created radiobuttons in a table. I wnat some of the radio buttons to fire events when their ..CheckChanged property has changed. I understand and was told this can be done with events and delegates. But my code would not compile. Here is what i did.
5
1717
by: karthick raja | last post by:
Am experiencing a problem intercepting the events from controls added dynamically to a Placeholder control at runtime. Is there any way that I can write an event handler on the page which will be pick up the events raised by the added controls dynamically. I cannot use 'WithEvents' and 'Handles' because this requires that the controls be declared on the page and they aren't (they are created in the external class) I did think of using...
1
1400
by: Paul | last post by:
An early Happy Thanksgiving to you and yours... We develop data driven apps. We dynamically place controls on a panel which may be then be placed on a web form or another control. My problem is that I can't get the events of the hosted controls to fire. e.g. ' myUserControl.ascx. is placed on myWebForm.aspx in the Designer ' myUserControl.ascx has a Panel on it, Panel1 ' From code in myUserControl.ascx I pass Panel1 ByRef to a class...
9
2308
by: Erik Frey | last post by:
Hi there, Just curious as to whether there's a clever way to see the events a control/object is firing off, perhaps written out to the debug console. It would be really handy to know which events a control is firing when I perform a certain action, and the order in which they are occurring. Thanks, Erik
2
1652
by: Nathan Sokalski | last post by:
I have LinkButtons that are dynamically created in one of the PostBack events. They must be created in the PostBack event because one of the variables required to determine which ones to create comes from the event arguments. Because the LinkButtons are not created in the Init event, they will not exist when I click them to perform a postback. How do I handle the events for these LinkButtons? I appreciate any help you can give. Thanks. --...
8
1899
by: Jonathan Wood | last post by:
I want to dynamically set my site's theme based on a setting stored in my database. I just hooked this up but get an error that the theme can only be set in the page's PreInit event or earlier. However, it appears that Master pages do not have PreInit events. I REALLY do not want to have to stick the same code in each and every page I create. How are you folks dynamically setting themes from master pages?
0
9632
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
10136
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10071
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
8958
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
7478
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
5372
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5501
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2867
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.