473,545 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom Object property not working

I'm trying to create a custom js object to display help text when you
move the mouse over controls on a form. I've got two issues that are
troubling:

1) The 'color' and 'backgroundColo r' properties only have values
immediately after you set them. Trying to access them from within the
object later with this.color yields "undefined"

2) Having trouble with the syntax for addEventListene r. Can't get
that to work in IE6 so I'm currently overwriting any preexisting
'onmouseover' events.

Any ideas on how to get either of these to work?

Thanks,
Jesse
<html>
<head>
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
<TITLE></TITLE>
<STYLE>
BODY{ margin:.5em; font-family:sans-serif}
DIV{ margin:0px; padding:.5em; height:3em; width:50%;
float:left; }
H6{ margin:0px; }
INPUT{ width:100% }
</STYLE>
<script>

function HelpText(color, bgColor){
var _lastEl;

this.color=colo r;
this.background Color=bgColor;

this.doMouseOve r=
function(){
//Exit if the pointer is over the same control
el=window.event .srcElement;
if(el == _lastEl) return false;
_lastEl=el;

//Get the div above this control
while(el.tagNam e != "DIV" && el.tagName != "BODY"){
el=el.parentNod e;
}

if(el.help && el.help.length != 0){
dvHelp.innerHTM L=el.help;
dvHelp.style.di splay="inline";
dvHelp.style.co lor=this.color;
dvHelp.style.ba ckgroundColor=t his.backgroundC olor;
window.status = this.background Color;
}

}

this.doMouseOut =
function(){
dvHelp.innerHTM L="";
dvHelp.style.di splay="none";
}
dvHelp=document .createElement( "DIV")
dvHelp.style.di splay="none";
window.document .body.appendChi ld(dvHelp);

window.document .body.onmouseov er=this.doMouse Over;
window.document .body.onmouseou t=this.doMouseO ut;
//window.document .addEventListen er("onmouseout" ,
this.doMouseOut , false);
}
</script>
</head>
<BODY onload="var oHelp=new HelpText('black ','yellow');">
<DIV help="First name of customer as it appears on credit card">
<H6>First Name</H6>
<INPUT type="text" ID="Text1" NAME="Text1">
</DIV>
<DIV help="Last name of customer as it appears on credit card">
<H6>Last Name</H6>
<INPUT type="text" ID="Text2" NAME="Text2">
</DIV>
<DIV help="Preferred shackle chain color">
<H6>Chain Color</H6>
<INPUT type="text" ID="Text3" NAME="Text3">
</DIV>
<DIV help="Name of customer's fantasy alter ego">
<H6>Alter Ego</H6>
<INPUT type="text" ID="Text4" NAME="Text4">
</DIV>
</BODY>
</html>
Jul 20 '05 #1
4 3680

"Jesse Wade" <jw***@rubytues day.com> schrieb im Newsbeitrag news:9d******** *************** ***@posting.goo gle.com...
I'm trying to create a custom js object to display help text when you
move the mouse over controls on a form. I've got two issues that are
troubling:

1) The 'color' and 'backgroundColo r' properties only have values
immediately after you set them. Trying to access them from within the
object later with this.color yields "undefined"

2) Having trouble with the syntax for addEventListene r. Can't get
that to work in IE6 so I'm currently overwriting any preexisting
'onmouseover' events.

Any ideas on how to get either of these to work?


For browser-independent event listeners, you could use my ISKEET
library v0.0.4 or later.

http://www.iskeet.de

It also simplifies the handling of page elements.

To find an element on the page, define a tag with an ID field,
which you've already done, as in:

<input id="text1" name="text1" type="text">

Then, you can use ISKEET_DEO.find ElementById() in the script
to retrieve the element:

var text1elem = ISKEET_DEO.find ElementById( "text1" );
if ( text1elem != undefined ) {
...
}

To set an event handler for it, simply do

ISKEET_DEO.addE ventHandler( "mouseover" , text1elem, doMouseOver );
ISKEET_DEO.addE ventHandler( "mouseout", text1elem, doMouseOut );

So, you can do something like:

var text1elem = ISKEET_DEO.find ElementById( "text1" );
if ( text1elem != undefined ) {
ISKEET_DEO.addE ventHandler( "mouseover" , text1elem, doMouseOver );
ISKEET_DEO.addE ventHandler( "mouseout", text1elem, doMouseOut );
}

To add a load handler for a window, write:

ISKEET_DEO.addE ventHandler( "load", window, doLoad );

I hope this helps! :-)
Jul 20 '05 #2

"Ekkehard Morgenstern" <ek************ ******@onlineho me.de> wrote:
var text1elem = ISKEET_DEO.find ElementById( "text1" );


duh, this should read:

var text1elem = ISKEET_DEO.getE lementById( "text1" );
Jul 20 '05 #3
While I appreciate the reply, your response doesn't help me learn why my
custom object doesn't work, does it? I figured half of it out on my
own. The property references don't work because "this" in the context
of the event handler doesn't refer to the custom object.
Best Regards,

Jesse Wade
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4

"Jesse Wade" <jw***@rubytues day.com> wrote:
While I appreciate the reply, your response doesn't help me learn why my
custom object doesn't work, does it? I figured half of it out on my
own. The property references don't work because "this" in the context
of the event handler doesn't refer to the custom object.


this, and addEventListene r() is only supported by DOM 2.0 events,
which are not supported by IE 6, hence that wouldn't work. ;-)
Jul 20 '05 #5

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

Similar topics

3
1526
by: Steve | last post by:
Guys, I've written a custom control (or at least tweaked someone else's!) in C# to be used on forms (rather than asp.net forms). The control is a date time picker, but its Value property returns a special date time object we have written, when a date is selected. The property object's class is called OptionalDateTime. This is basically to...
4
1905
by: Rudy | last post by:
Hello all, I'm sure there is, just can't figure it out. I have the RGB code and the color number. But the color doesn't exsist in Visual studio.net. Can I add this color to the system pallet it self, so I can add the custom color to fonts? I need to match as close as possible to the color I was given. Thanks Rudy
5
34935
by: Steven Baggs | last post by:
Hi!, I have defined a List<T> like this List<Container> Container class holds my Item object and it's state as a Enum. Container.Item Container.State I would like to bind it to GridView.
6
1571
by: Steve Amey | last post by:
Hi all I want to be able to throw a custom error up the call stack. I have looked around and it seems as though it's possible, but I can't get it to work :o( Below is some sample code. ------------------------------------------------------------ Public Class MainForm Public Sub Show Form Try
2
2423
by: AMDRIT | last post by:
Hello everyone, I have created a custom component and one of its properties is a class object with it's own properties. During runtime, I can assign values to the class object properties just fine. However, when attempting to assing default values as designtime in the propertygrid, nothing is working on the class object. I know that I...
9
4675
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate> /asp:Repeater> The DataSource for this Repeater is a CollectionBase of objects and is
19
4896
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the exception of custom Collection Classes. Background: I'm developing an A2K .mdb to be deployed as an .mde at my current job-site. It has several custom...
0
1934
by: ChopStickr | last post by:
I have a custom control that is embedded (using the object tag) in an html document. The control takes a path to a local client ini file. Reads the file. Executes the program specified in the ini on the client's PC. After the program has ended the control looks in a client side temp folder (specified by the ini file) for an image created...
4
3888
by: Linda Liu[MSFT] | last post by:
Hi Moondaddy, I downloaded your sample project and run it and did see the problem on my side. There're three problems in the source code of your project. 1. You should move the following lines of code from the GetGeometry method within the CustomPolyLine class: _points.Add(new Point(10, 10));
4
2469
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried unsuccessfully in creating the whole pane as a user control and have succeeded in adding the pane and then dynamically adding the content which is a user...
0
7410
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7668
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. ...
1
7437
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
7773
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
5984
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
5343
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
3466
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...
0
3448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1025
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.