Re: [OT] DOM & JavaScript

2005-04-28 Thread gdeschen
Well thanks again ! 
I did remember that thread and did not have the time to follow its lengthy 
trail.

- Glenn




"Frank W. Zammetti" <[EMAIL PROTECTED]> 
28/04/2005 12:54 PM
Please respond to
"Struts Users Mailing List" 


To
"Struts Users Mailing List" 
cc
"Struts Users Mailing List" 
Subject
Re: [OT] DOM & JavaScript
Classification








Actually, I'm not entirely sure :)  I can't remember ever using an
anonymous function in JS myself frankly, but I remembered a sample that
Martin posted a week or so ago during our discussion on Ajax, and it just
kind of clicked!

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Thu, April 28, 2005 12:51 pm, [EMAIL PROTECTED] said:
> Excellent Frank, thanks a million !!!
> What was your inspiration for this ?
>
> - Glenn
>
>
>
>
> "Frank W. Zammetti" <[EMAIL PROTECTED]>
> 28/04/2005 10:47 AM
> Please respond to
> "Struts Users Mailing List" 
>
>
> To
> "Struts Users Mailing List" 
> cc
> "Struts Users Mailing List" 
> Subject
> Re: [OT] DOM & JavaScript
> Classification
>
>
>
>
>
>
>
>
> Ah, got it!  You can use an anonymous function... The suggestion of
> setting a common handler is fine except that you will have to use
> getElementById to get a reference to the element to change... using an
> anonymous function you have access to the this keyword, so it's cleaner.
> Here's a complete working page (at least in IE)...
>
> 
> 
> Test
> 
>   .hilite { background-color:#ff; }
>   .normal { background-color:#ff; }
> 
> 
> function createTable(table) {
>   row = table.insertRow();
>   row.setAttribute("className", "normal");
>   row.onmouseover = function() { this.className='hilite'; }
>   row.onmouseout = function() { this.className='normal'; }
>   cell = row.insertCell();
>   cell.innerHTML = "new1";
>   cell = row.insertCell();
>   cell.innerHTML = "new2";
> }
> 
> 
> 
> 
>onMouseOut="this.className='normal';">
> dummy1dummy2
>   
> 
> 
> 
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
>
> On Thu, April 28, 2005 9:58 am, [EMAIL PROTECTED] said:
>> Merci Laurent !
>>
>> Okay so then when you say that it must be functions..
>> I presume that the HTML with coded attributes such as onMouseOver and
>> onMouseOut... in IE the browser parses the data and internally creates
>> functions to handle the mouse events.
>> So when I try to dynamically modify the DOM for IE... I must recreate
> the
>> mouse handlers.
>> Would this be a valid way of describing the situation?
>>
>> I must now understand the element hierarchy along with the event firing
>> sequence...
>> Since I'd like to hilite the row... now it is hiliting the cell of a
>> row... :(
>>
>> - Glenn
>>
>>
>>
>> Laurent <[EMAIL PROTECTED]>
>> 28/04/2005 09:11 AM
>> Please respond to
>> "Struts Users Mailing List" 
>>
>>
>> To
>> Struts Users Mailing List 
>> cc
>>
>> Subject
>> Re: [OT] DOM & JavaScript
>> Classification
>>
>>
>>
>>
>>
>>
>>
>>
>> [EMAIL PROTECTED] wrote:
>>> // Only add a row when changing the last row of the table
>>> if ("s"+(rowWithData) == selectId) {
>>> var row = table.insertRow(lastRowInTable);
>>> var className = "rowNormal";
>>>
>>> if (lastRowInTable % 2 == 0) {
>>> className = "rowAlternate";
>>> }
>>> row.className = className;
>>> row.setAttribute("onmouseover", "this.className = 'hilite';");
>>> row.setAttribute("onmouseout", "this.className = '" + 
className
>> +
>>> "'");
>>
>>
>> That's not how it works (not in IE at least). The event attributes'
>> values should be event listeners (i.e. functions), not strings of
>> javascript code.
>>
>> Try this:
>>
>> function changeClassName(e) {
>>   if (!e) e=window.event;
>>   getEventTarget(e).setAttribute("class", "hilite"); // DOM-compliant
>>   getEventTarget(e).setAttribute("className", "hilite"); // MSIE
>> }
>>
>> row.onmouseover = changeClassName; // without quotes nor parentheses
>>
>> function getEventTarget(e) {
>> if (e.srcElement) return e.srcElement;
>> else return e.currentTarget;
>> }
>>
>> Note: the code above aims to be cross-browser, as IE behaves completely
>> differently from any other browser.
>>
>> BTW, all event attributes are *lower case*: onmouseover, onmouseout 
(not
>> onMouseOver...)
>>
>> Hope this helps.
>>
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Re: [OT] DOM & JavaScript

2005-04-28 Thread Frank W. Zammetti
Actually, I'm not entirely sure :)  I can't remember ever using an
anonymous function in JS myself frankly, but I remembered a sample that
Martin posted a week or so ago during our discussion on Ajax, and it just
kind of clicked!

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Thu, April 28, 2005 12:51 pm, [EMAIL PROTECTED] said:
> Excellent Frank, thanks a million !!!
> What was your inspiration for this ?
>
> - Glenn
>
>
>
>
> "Frank W. Zammetti" <[EMAIL PROTECTED]>
> 28/04/2005 10:47 AM
> Please respond to
> "Struts Users Mailing List" 
>
>
> To
> "Struts Users Mailing List" 
> cc
> "Struts Users Mailing List" 
> Subject
> Re: [OT] DOM & JavaScript
> Classification
>
>
>
>
>
>
>
>
> Ah, got it!  You can use an anonymous function... The suggestion of
> setting a common handler is fine except that you will have to use
> getElementById to get a reference to the element to change... using an
> anonymous function you have access to the this keyword, so it's cleaner.
> Here's a complete working page (at least in IE)...
>
> 
> 
> Test
> 
>   .hilite { background-color:#ff; }
>   .normal { background-color:#ff; }
> 
> 
> function createTable(table) {
>   row = table.insertRow();
>   row.setAttribute("className", "normal");
>   row.onmouseover = function() { this.className='hilite'; }
>   row.onmouseout = function() { this.className='normal'; }
>   cell = row.insertCell();
>   cell.innerHTML = "new1";
>   cell = row.insertCell();
>   cell.innerHTML = "new2";
> }
> 
> 
> 
> 
>onMouseOut="this.className='normal';">
> dummy1dummy2
>   
> 
> 
> 
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
>
> On Thu, April 28, 2005 9:58 am, [EMAIL PROTECTED] said:
>> Merci Laurent !
>>
>> Okay so then when you say that it must be functions..
>> I presume that the HTML with coded attributes such as onMouseOver and
>> onMouseOut... in IE the browser parses the data and internally creates
>> functions to handle the mouse events.
>> So when I try to dynamically modify the DOM for IE... I must recreate
> the
>> mouse handlers.
>> Would this be a valid way of describing the situation?
>>
>> I must now understand the element hierarchy along with the event firing
>> sequence...
>> Since I'd like to hilite the row... now it is hiliting the cell of a
>> row... :(
>>
>> - Glenn
>>
>>
>>
>> Laurent <[EMAIL PROTECTED]>
>> 28/04/2005 09:11 AM
>> Please respond to
>> "Struts Users Mailing List" 
>>
>>
>> To
>> Struts Users Mailing List 
>> cc
>>
>> Subject
>> Re: [OT] DOM & JavaScript
>> Classification
>>
>>
>>
>>
>>
>>
>>
>>
>> [EMAIL PROTECTED] wrote:
>>> // Only add a row when changing the last row of the table
>>> if ("s"+(rowWithData) == selectId) {
>>> var row = table.insertRow(lastRowInTable);
>>> var className = "rowNormal";
>>>
>>> if (lastRowInTable % 2 == 0) {
>>> className = "rowAlternate";
>>> }
>>> row.className = className;
>>> row.setAttribute("onmouseover", "this.className = 'hilite';");
>>> row.setAttribute("onmouseout", "this.className = '" + className
>> +
>>> "'");
>>
>>
>> That's not how it works (not in IE at least). The event attributes'
>> values should be event listeners (i.e. functions), not strings of
>> javascript code.
>>
>> Try this:
>>
>> function changeClassName(e) {
>>   if (!e) e=window.event;
>>   getEventTarget(e).setAttribute("class", "hilite"); // DOM-compliant
>>   getEventTarget(e).setAttribute("className", "hilite"); // MSIE
>> }
>>
>> row.onmouseover = changeClassName; // without quotes nor parentheses
>>
>> function getEventTarget(e) {
>> if (e.srcElement) return e.srcElement;
>> else return e.currentTarget;
>> }
>>
>> Note: the code above aims to be cross-browser, as IE behaves completely
>> differently from any other browser.
>>
>> BTW, all event attributes are *lower case*: onmouseover, onmouseout (not
>> onMouseOver...)
>>
>> Hope this helps.
>>
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] DOM & JavaScript

2005-04-28 Thread gdeschen
Excellent Frank, thanks a million !!!
What was your inspiration for this ?

- Glenn




"Frank W. Zammetti" <[EMAIL PROTECTED]> 
28/04/2005 10:47 AM
Please respond to
"Struts Users Mailing List" 


To
"Struts Users Mailing List" 
cc
"Struts Users Mailing List" 
Subject
Re: [OT] DOM & JavaScript
Classification








Ah, got it!  You can use an anonymous function... The suggestion of
setting a common handler is fine except that you will have to use
getElementById to get a reference to the element to change... using an
anonymous function you have access to the this keyword, so it's cleaner. 
Here's a complete working page (at least in IE)...



Test

  .hilite { background-color:#ff; }
  .normal { background-color:#ff; }


function createTable(table) {
  row = table.insertRow();
  row.setAttribute("className", "normal");
  row.onmouseover = function() { this.className='hilite'; }
  row.onmouseout = function() { this.className='normal'; }
  cell = row.insertCell();
  cell.innerHTML = "new1";
  cell = row.insertCell();
  cell.innerHTML = "new2";
}




  
dummy1dummy2
  




-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Thu, April 28, 2005 9:58 am, [EMAIL PROTECTED] said:
> Merci Laurent !
>
> Okay so then when you say that it must be functions..
> I presume that the HTML with coded attributes such as onMouseOver and
> onMouseOut... in IE the browser parses the data and internally creates
> functions to handle the mouse events.
> So when I try to dynamically modify the DOM for IE... I must recreate 
the
> mouse handlers.
> Would this be a valid way of describing the situation?
>
> I must now understand the element hierarchy along with the event firing
> sequence...
> Since I'd like to hilite the row... now it is hiliting the cell of a
> row... :(
>
> - Glenn
>
>
>
> Laurent <[EMAIL PROTECTED]>
> 28/04/2005 09:11 AM
> Please respond to
> "Struts Users Mailing List" 
>
>
> To
> Struts Users Mailing List 
> cc
>
> Subject
> Re: [OT] DOM & JavaScript
> Classification
>
>
>
>
>
>
>
>
> [EMAIL PROTECTED] wrote:
>> // Only add a row when changing the last row of the table
>> if ("s"+(rowWithData) == selectId) {
>> var row = table.insertRow(lastRowInTable);
>> var className = "rowNormal";
>>
>> if (lastRowInTable % 2 == 0) {
>> className = "rowAlternate";
>> }
>> row.className = className;
>> row.setAttribute("onmouseover", "this.className = 'hilite';");
>> row.setAttribute("onmouseout", "this.className = '" + className
> +
>> "'");
>
>
> That's not how it works (not in IE at least). The event attributes'
> values should be event listeners (i.e. functions), not strings of
> javascript code.
>
> Try this:
>
> function changeClassName(e) {
>   if (!e) e=window.event;
>   getEventTarget(e).setAttribute("class", "hilite"); // DOM-compliant
>   getEventTarget(e).setAttribute("className", "hilite"); // MSIE
> }
>
> row.onmouseover = changeClassName; // without quotes nor parentheses
>
> function getEventTarget(e) {
> if (e.srcElement) return e.srcElement;
> else return e.currentTarget;
> }
>
> Note: the code above aims to be cross-browser, as IE behaves completely
> differently from any other browser.
>
> BTW, all event attributes are *lower case*: onmouseover, onmouseout (not
> onMouseOver...)
>
> Hope this helps.
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Re: [OT] DOM & JavaScript

2005-04-28 Thread Frank W. Zammetti
Ah, got it!  You can use an anonymous function... The suggestion of
setting a common handler is fine except that you will have to use
getElementById to get a reference to the element to change... using an
anonymous function you have access to the this keyword, so it's cleaner. 
Here's a complete working page (at least in IE)...



Test

  .hilite { background-color:#ff; }
  .normal { background-color:#ff; }


function createTable(table) {
  row = table.insertRow();
  row.setAttribute("className", "normal");
  row.onmouseover = function() { this.className='hilite'; }
  row.onmouseout = function() { this.className='normal'; }
  cell = row.insertCell();
  cell.innerHTML = "new1";
  cell = row.insertCell();
  cell.innerHTML = "new2";
}




  
dummy1dummy2
  




-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Thu, April 28, 2005 9:58 am, [EMAIL PROTECTED] said:
> Merci Laurent !
>
> Okay so then when you say that it must be functions..
> I presume that the HTML with coded attributes such as onMouseOver and
> onMouseOut... in IE the browser parses the data and internally creates
> functions to handle the mouse events.
> So when I try to dynamically modify the DOM for IE... I must recreate the
> mouse handlers.
> Would this be a valid way of describing the situation?
>
> I must now understand the element hierarchy along with the event firing
> sequence...
> Since I'd like to hilite the row... now it is hiliting the cell of a
> row... :(
>
> - Glenn
>
>
>
> Laurent <[EMAIL PROTECTED]>
> 28/04/2005 09:11 AM
> Please respond to
> "Struts Users Mailing List" 
>
>
> To
> Struts Users Mailing List 
> cc
>
> Subject
> Re: [OT] DOM & JavaScript
> Classification
>
>
>
>
>
>
>
>
> [EMAIL PROTECTED] wrote:
>> // Only add a row when changing the last row of the table
>> if ("s"+(rowWithData) == selectId) {
>> var row = table.insertRow(lastRowInTable);
>> var className = "rowNormal";
>>
>> if (lastRowInTable % 2 == 0) {
>> className = "rowAlternate";
>> }
>> row.className = className;
>> row.setAttribute("onmouseover", "this.className = 'hilite';");
>> row.setAttribute("onmouseout", "this.className = '" + className
> +
>> "'");
>
>
> That's not how it works (not in IE at least). The event attributes'
> values should be event listeners (i.e. functions), not strings of
> javascript code.
>
> Try this:
>
> function changeClassName(e) {
>   if (!e) e=window.event;
>   getEventTarget(e).setAttribute("class", "hilite"); // DOM-compliant
>   getEventTarget(e).setAttribute("className", "hilite"); // MSIE
> }
>
> row.onmouseover = changeClassName; // without quotes nor parentheses
>
> function getEventTarget(e) {
> if (e.srcElement) return e.srcElement;
> else return e.currentTarget;
> }
>
> Note: the code above aims to be cross-browser, as IE behaves completely
> differently from any other browser.
>
> BTW, all event attributes are *lower case*: onmouseover, onmouseout (not
> onMouseOver...)
>
> Hope this helps.
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] DOM & JavaScript

2005-04-28 Thread gdeschen
Merci Laurent !

Okay so then when you say that it must be functions..
I presume that the HTML with coded attributes such as onMouseOver and 
onMouseOut... in IE the browser parses the data and internally creates 
functions to handle the mouse events.
So when I try to dynamically modify the DOM for IE... I must recreate the 
mouse handlers.
Would this be a valid way of describing the situation?

I must now understand the element hierarchy along with the event firing 
sequence...
Since I'd like to hilite the row... now it is hiliting the cell of a 
row... :(

- Glenn



Laurent <[EMAIL PROTECTED]> 
28/04/2005 09:11 AM
Please respond to
"Struts Users Mailing List" 


To
Struts Users Mailing List 
cc

Subject
Re: [OT] DOM & JavaScript
Classification








[EMAIL PROTECTED] wrote:
> // Only add a row when changing the last row of the table
> if ("s"+(rowWithData) == selectId) {
> var row = table.insertRow(lastRowInTable);
> var className = "rowNormal";
> 
> if (lastRowInTable % 2 == 0) {
> className = "rowAlternate";
> }
> row.className = className;
> row.setAttribute("onmouseover", "this.className = 'hilite';");
> row.setAttribute("onmouseout", "this.className = '" + className 
+ 
> "'");


That's not how it works (not in IE at least). The event attributes'
values should be event listeners (i.e. functions), not strings of
javascript code.

Try this:

function changeClassName(e) {
  if (!e) e=window.event;
  getEventTarget(e).setAttribute("class", "hilite"); // DOM-compliant
  getEventTarget(e).setAttribute("className", "hilite"); // MSIE
}

row.onmouseover = changeClassName; // without quotes nor parentheses

function getEventTarget(e) {
if (e.srcElement) return e.srcElement;
else return e.currentTarget;
}

Note: the code above aims to be cross-browser, as IE behaves completely
differently from any other browser.

BTW, all event attributes are *lower case*: onmouseover, onmouseout (not
onMouseOver...)

Hope this helps.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Re: [OT] DOM & JavaScript

2005-04-28 Thread gdeschen
I also gave this a try without any succcess.
Thanks for your time and patience Frank !
(see my reply to Laurent).

- Glenn
 



"Frank W. Zammetti" <[EMAIL PROTECTED]> 
28/04/2005 09:10 AM
Please respond to
"Struts Users Mailing List" 


To
"Struts Users Mailing List" 
cc
"Struts Users Mailing List" 
Subject
Re: [OT] DOM & JavaScript
Classification








How about trying one last thing... how about instead of using the row
reference you get back from insertRow(), instead do a getElementById() to
get a new reference and try setting the handlers on that.

I'm grabbing at straws here admittedly, but it might be worth a try.  I've
seenstranger things :)

Incidentally, I found some code I wrote doing the same thing and although
I'm not using setAttribute (I think your right by the way about that being
the more standard-compliant way to do this) it does work.  That doesn't
much help of course :)  My code is virtually identical to yours too, in
fact it IS identical in the part that actually creates the table.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Thu, April 28, 2005 8:12 am, [EMAIL PROTECTED] said:
> Okay Frank I gave it a shot and still nothing.
> I believe that the setAttribute is the proper way according to the DOM
> API.
> The other way may be supported depending on the browser.
>
> But in the end it is still not working.
> I'm thinking of an alternate solution, since the page is complete except
> for the damn mouse handlers.
> It would be a drag if I have to drop this feature since the web
> application has it in all of the pages... but this is the first dynamic
> page.
> I'm wondering if creating a global handler for mouse events would help.
>
> - Glenn
>
>
>
>
> "Frank W. Zammetti" <[EMAIL PROTECTED]>
> 27/04/2005 05:13 PM
> Please respond to
> "Struts Users Mailing List" 
>
>
> To
> Struts Users Mailing List 
> cc
>
> Subject
> Re: [OT] DOM & JavaScript
> Classification
>
>
>
>
>
>
>
>
> Interesting indeed... How about trying this... change the two lines that
> dynamically add the mouse handlers to:
>
> row.onMouseOver = "this.className = 'hilite';";
> row.onMouseOut = "this.className = 'rowNormal';";
>
> I'm not 100% sure what the capitalization should be of the property your
> setting (i.e., row.onMouseOver vs. row.onmouseover vs. something else),
> but give that a shot... any time I've done dynamic table creation I
> don't remember ever using setAttribute() at all, I think I've written
> code like the above.
>
> Frank
>
> [EMAIL PROTECTED] wrote:
>> Curiously... the mouse events are all in lowercase when they are shown
> in
>> the dump.
>> 
>> 
>> Effective Date
>> CWW Schedule Type
>>  width=74>Delete
>> 
>>
>> - - - - - This is from the JSP - - - - - - -
>> > onmouseout="this.className = 'rowNormal'" valign="top">
>> 03 January 2004 
>> > href="#">> border=0> 
>> > onchange="addTableRow('historyTable','s0')"
>> name=historyItems[0].scheduleTypeId> > value=01 selected>1 Week Cycle 2 Week
>> Cycle 3 Week Cycle 4
>
>> Week Cycle Regular Week
>> Schedule 
>> > name=historyItems[0].delete> 
>> > style="VISIBILITY: hidden" size=1 value=2004-01-03
>> name=historyItems[0].startDate> 
>>
>> - - - - - - - This is the row added dynamically - - - - - - -
>> > onmouseout="this.className = 'rowNormal'" valign="top">
>> 
>> > href="
> 
http://nati02:5001/hronline/secure/WEB-INF/personal/timeAndAttendance/cWWHistory.jsp#

> ">> height=16 src="http://nati02:5001/hronline/images/calendar.jpg"; 
width=16
>
>> border=0> 
>> > onchange="addTableRow('historyTable','s4')"
>> name=historyItems[4].scheduleTypeId>
>> 1 Week Cycle 2 Week
>> Cycle 3 Week Cycle 4
>
>> Week Cycle Regular Week
>> Schedule 
>> > name=historyItems[4].delete> 
>> > style="VISIBILITY: hidden" size=1 value=2004-01-03
>> name=historyItems[4].startDate> 
>>
>> - Glenn
>>
>>
>>
>>
>> "Frank W. Zammetti" <[EMAIL PROTECTED]>
>> 27/04/2005 04:27 PM
>> Please respond to
>> "Struts Users Mailing List" 
>>
>>
>> To
>> Struts Users Mailing List 
>> cc
>>
>> Subj

Re: [OT] DOM & JavaScript

2005-04-28 Thread Laurent
[EMAIL PROTECTED] wrote:
> // Only add a row when changing the last row of the table
> if ("s"+(rowWithData) == selectId) {
> var row = table.insertRow(lastRowInTable);
> var className = "rowNormal";
> 
> if (lastRowInTable % 2 == 0) {
> className = "rowAlternate";
> }
> row.className = className;
> row.setAttribute("onmouseover", "this.className = 'hilite';");
> row.setAttribute("onmouseout", "this.className = '" + className + 
> "'");


That's not how it works (not in IE at least). The event attributes'
values should be event listeners (i.e. functions), not strings of
javascript code.

Try this:

function changeClassName(e) {
  if (!e) e=window.event;
  getEventTarget(e).setAttribute("class", "hilite"); // DOM-compliant
  getEventTarget(e).setAttribute("className", "hilite"); // MSIE
}

row.onmouseover = changeClassName; // without quotes nor parentheses

function getEventTarget(e) {
if (e.srcElement) return e.srcElement;
else return e.currentTarget;
}

Note: the code above aims to be cross-browser, as IE behaves completely
differently from any other browser.

BTW, all event attributes are *lower case*: onmouseover, onmouseout (not
onMouseOver...)

Hope this helps.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [OT] DOM & JavaScript

2005-04-28 Thread Frank W. Zammetti
How about trying one last thing... how about instead of using the row
reference you get back from insertRow(), instead do a getElementById() to
get a new reference and try setting the handlers on that.

I'm grabbing at straws here admittedly, but it might be worth a try.  I've
seenstranger things :)

Incidentally, I found some code I wrote doing the same thing and although
I'm not using setAttribute (I think your right by the way about that being
the more standard-compliant way to do this) it does work.  That doesn't
much help of course :)  My code is virtually identical to yours too, in
fact it IS identical in the part that actually creates the table.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Thu, April 28, 2005 8:12 am, [EMAIL PROTECTED] said:
> Okay Frank I gave it a shot and still nothing.
> I believe that the setAttribute is the proper way according to the DOM
> API.
> The other way may be supported depending on the browser.
>
> But in the end it is still not working.
> I'm thinking of an alternate solution, since the page is complete except
> for the damn mouse handlers.
> It would be a drag if I have to drop this feature since the web
> application has it in all of the pages... but this is the first dynamic
> page.
> I'm wondering if creating a global handler for mouse events would help.
>
> - Glenn
>
>
>
>
> "Frank W. Zammetti" <[EMAIL PROTECTED]>
> 27/04/2005 05:13 PM
> Please respond to
> "Struts Users Mailing List" 
>
>
> To
> Struts Users Mailing List 
> cc
>
> Subject
> Re: [OT] DOM & JavaScript
> Classification
>
>
>
>
>
>
>
>
> Interesting indeed... How about trying this... change the two lines that
> dynamically add the mouse handlers to:
>
> row.onMouseOver = "this.className = 'hilite';";
> row.onMouseOut = "this.className = 'rowNormal';";
>
> I'm not 100% sure what the capitalization should be of the property your
> setting (i.e., row.onMouseOver vs. row.onmouseover vs. something else),
> but give that a shot... any time I've done dynamic table creation I
> don't remember ever using setAttribute() at all, I think I've written
> code like the above.
>
> Frank
>
> [EMAIL PROTECTED] wrote:
>> Curiously... the mouse events are all in lowercase when they are shown
> in
>> the dump.
>> 
>> 
>> Effective Date
>> CWW Schedule Type
>>  width=74>Delete
>> 
>>
>> - - - - - This is from the JSP - - - - - - -
>> > onmouseout="this.className = 'rowNormal'" valign="top">
>> 03 January 2004 
>> > href="#">> border=0> 
>> > onchange="addTableRow('historyTable','s0')"
>> name=historyItems[0].scheduleTypeId> > value=01 selected>1 Week Cycle 2 Week
>> Cycle 3 Week Cycle 4
>
>> Week Cycle Regular Week
>> Schedule 
>> > name=historyItems[0].delete> 
>> > style="VISIBILITY: hidden" size=1 value=2004-01-03
>> name=historyItems[0].startDate> 
>>
>> - - - - - - - This is the row added dynamically - - - - - - -
>> > onmouseout="this.className = 'rowNormal'" valign="top">
>> 
>> > href="
> http://nati02:5001/hronline/secure/WEB-INF/personal/timeAndAttendance/cWWHistory.jsp#
> ">> height=16 src="http://nati02:5001/hronline/images/calendar.jpg"; width=16
>
>> border=0> 
>> > onchange="addTableRow('historyTable','s4')"
>> name=historyItems[4].scheduleTypeId>
>> 1 Week Cycle 2 Week
>> Cycle 3 Week Cycle 4
>
>> Week Cycle Regular Week
>> Schedule 
>> > name=historyItems[4].delete> 
>> > style="VISIBILITY: hidden" size=1 value=2004-01-03
>> name=historyItems[4].startDate> 
>>
>> - Glenn
>>
>>
>>
>>
>> "Frank W. Zammetti" <[EMAIL PROTECTED]>
>> 27/04/2005 04:27 PM
>> Please respond to
>> "Struts Users Mailing List" 
>>
>>
>> To
>> Struts Users Mailing List 
>> cc
>>
>> Subject
>> Re: [OT] DOM & JavaScript
>> Classification
>>
>>
>>
>>
>>
>>
>>
>>
>> Hmm... I notice that the JSP code is referencing onMouseOver, while your
>
>> Javascript is trying to set the attribute onmouseover... I wonder if the
>
>> capitalization difference is an issue?  Certainly, if setAttribute()
>> tak

Re: [OT] DOM & JavaScript

2005-04-28 Thread gdeschen
Okay Frank I gave it a shot and still nothing.
I believe that the setAttribute is the proper way according to the DOM 
API.
The other way may be supported depending on the browser.

But in the end it is still not working.
I'm thinking of an alternate solution, since the page is complete except 
for the damn mouse handlers.
It would be a drag if I have to drop this feature since the web 
application has it in all of the pages... but this is the first dynamic 
page.
I'm wondering if creating a global handler for mouse events would help.

- Glenn




"Frank W. Zammetti" <[EMAIL PROTECTED]> 
27/04/2005 05:13 PM
Please respond to
"Struts Users Mailing List" 


To
Struts Users Mailing List 
cc

Subject
Re: [OT] DOM & JavaScript
Classification








Interesting indeed... How about trying this... change the two lines that 
dynamically add the mouse handlers to:

row.onMouseOver = "this.className = 'hilite';";
row.onMouseOut = "this.className = 'rowNormal';";

I'm not 100% sure what the capitalization should be of the property your 
setting (i.e., row.onMouseOver vs. row.onmouseover vs. something else), 
but give that a shot... any time I've done dynamic table creation I 
don't remember ever using setAttribute() at all, I think I've written 
code like the above.

Frank

[EMAIL PROTECTED] wrote:
> Curiously... the mouse events are all in lowercase when they are shown 
in 
> the dump.
> 
> 
> Effective Date
> CWW Schedule Type
> Delete
> 
> 
> - - - - - This is from the JSP - - - - - - -
>  onmouseout="this.className = 'rowNormal'" valign="top">
> 03 January 2004 
>  href="#"> border=0> 
>  onchange="addTableRow('historyTable','s0')" 
> name=historyItems[0].scheduleTypeId>  value=01 selected>1 Week Cycle 2 Week 
> Cycle 3 Week Cycle 4 

> Week Cycle Regular Week 
> Schedule 
>  name=historyItems[0].delete> 
>  style="VISIBILITY: hidden" size=1 value=2004-01-03 
> name=historyItems[0].startDate> 
> 
> - - - - - - - This is the row added dynamically - - - - - - -
>  onmouseout="this.className = 'rowNormal'" valign="top">
> 
>  href="
http://nati02:5001/hronline/secure/WEB-INF/personal/timeAndAttendance/cWWHistory.jsp#
"> height=16 src="http://nati02:5001/hronline/images/calendar.jpg"; width=16 

> border=0> 
>  onchange="addTableRow('historyTable','s4')" 
> name=historyItems[4].scheduleTypeId> 
> 1 Week Cycle 2 Week 
> Cycle 3 Week Cycle 4 

> Week Cycle Regular Week 
> Schedule 
>  name=historyItems[4].delete> 
>  style="VISIBILITY: hidden" size=1 value=2004-01-03 
> name=historyItems[4].startDate> 
> 
> - Glenn
> 
> 
> 
> 
> "Frank W. Zammetti" <[EMAIL PROTECTED]> 
> 27/04/2005 04:27 PM
> Please respond to
> "Struts Users Mailing List" 
> 
> 
> To
> Struts Users Mailing List 
> cc
> 
> Subject
> Re: [OT] DOM & JavaScript
> Classification
> 
> 
> 
> 
> 
> 
> 
> 
> Hmm... I notice that the JSP code is referencing onMouseOver, while your 

> Javascript is trying to set the attribute onmouseover... I wonder if the 

> capitalization difference is an issue?  Certainly, if setAttribute() 
> takes case into consideration that would do it.  You said the lines were 

> identical when you looked, but could it be you glossed over the 
> difference in capitalization? (I may have too).
> 
> Frank
> 
> [EMAIL PROTECTED] wrote:
> 
>>Greetings,
>>
>>Once again I call on my trusted community for insight !
>>I'm adding a row to a table dynamically. All is working well except for 
>>one thing the Mouse events.
>>
>>Here is the code for adding a row to the table.
>>There is more code that adds the cells to the table (not shown).
>>...
>>// Only add a row when changing the last row of the table
>>if ("s"+(rowWithData) == selectId) {
>>var row = table.insertRow(lastRowInTable);
>>var className = "rowNormal";
>>
>>if (lastRowInTable % 2 == 0) {
>>className = "rowAlternate";
>>}
>>row.className = className;
>>row.setAttribute("onmouseover", "this.className = 'hilite';");
>>row.setAttribute("onmouseout", "this.className = '" + className 
> 
> + 
> 
>>"'");
>>...
>>}
>>
>>
>>Here is the JSP code that creates the table row (at least one row is in 
>>the page), here the mouse events are working:
>>>"this.className = ''" class=">'${rowClass}'/>">
>>
>>If I add an alert that dumps the innerHTML of the table after the 
>>row/cells are added and I compare the two rows... 
>>They are the same.
>>Why are the mouse events added dynamically not recongnized ?
>>
>>BTW, using IE 6.0.2900.2180.xpsp_sp2_rtm.040803-2158
>>
>>TIA,
>>Glenn
>>
> 
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Re: [OT] DOM & JavaScript

2005-04-27 Thread Frank W. Zammetti
Interesting indeed... How about trying this... change the two lines that 
dynamically add the mouse handlers to:

row.onMouseOver = "this.className = 'hilite';";
row.onMouseOut = "this.className = 'rowNormal';";
I'm not 100% sure what the capitalization should be of the property your 
setting (i.e., row.onMouseOver vs. row.onmouseover vs. something else), 
but give that a shot... any time I've done dynamic table creation I 
don't remember ever using setAttribute() at all, I think I've written 
code like the above.

Frank
[EMAIL PROTECTED] wrote:
Curiously... the mouse events are all in lowercase when they are shown in 
the dump.


Effective Date
CWW Schedule Type
Delete


- - - - - This is from the JSP - - - - - - -

03 January 2004 
 
 1 Week Cycle 2 Week 
Cycle 3 Week Cycle 4 
Week Cycle Regular Week 
Schedule 
 
 

- - - - - - - This is the row added dynamically - - - - - - -


http://nati02:5001/hronline/secure/WEB-INF/personal/timeAndAttendance/cWWHistory.jsp#";>http://nati02:5001/hronline/images/calendar.jpg"; width=16 
border=0> 
 
1 Week Cycle 2 Week 
Cycle 3 Week Cycle 4 
Week Cycle Regular Week 
Schedule 
 
 

- Glenn

"Frank W. Zammetti" <[EMAIL PROTECTED]> 
27/04/2005 04:27 PM
Please respond to
"Struts Users Mailing List" 

To
Struts Users Mailing List 
cc
Subject
Re: [OT] DOM & JavaScript
Classification



Hmm... I notice that the JSP code is referencing onMouseOver, while your 
Javascript is trying to set the attribute onmouseover... I wonder if the 
capitalization difference is an issue?  Certainly, if setAttribute() 
takes case into consideration that would do it.  You said the lines were 
identical when you looked, but could it be you glossed over the 
difference in capitalization? (I may have too).

Frank
[EMAIL PROTECTED] wrote:
Greetings,
Once again I call on my trusted community for insight !
I'm adding a row to a table dynamically. All is working well except for 
one thing the Mouse events.

Here is the code for adding a row to the table.
There is more code that adds the cells to the table (not shown).
...
// Only add a row when changing the last row of the table
if ("s"+(rowWithData) == selectId) {
   var row = table.insertRow(lastRowInTable);
   var className = "rowNormal";
   if (lastRowInTable % 2 == 0) {
   className = "rowAlternate";
   }
   row.className = className;
   row.setAttribute("onmouseover", "this.className = 'hilite';");
   row.setAttribute("onmouseout", "this.className = '" + className 
+ 

"'");
...
}
Here is the JSP code that creates the table row (at least one row is in 
the page), here the mouse events are working:

"this.className = ''" class="
'${rowClass}'/>">

If I add an alert that dumps the innerHTML of the table after the 
row/cells are added and I compare the two rows... 
They are the same.
Why are the mouse events added dynamically not recongnized ?

BTW, using IE 6.0.2900.2180.xpsp_sp2_rtm.040803-2158
TIA,
Glenn

--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [OT] DOM & JavaScript

2005-04-27 Thread gdeschen
Curiously... the mouse events are all in lowercase when they are shown in 
the dump.


Effective Date
CWW Schedule Type
Delete


- - - - - This is from the JSP - - - - - - -

03 January 2004 
 
 1 Week Cycle 2 Week 
Cycle 3 Week Cycle 4 
Week Cycle Regular Week 
Schedule 
 
 

- - - - - - - This is the row added dynamically - - - - - - -


http://nati02:5001/hronline/secure/WEB-INF/personal/timeAndAttendance/cWWHistory.jsp#";>http://nati02:5001/hronline/images/calendar.jpg"; width=16 
border=0> 
 
1 Week Cycle 2 Week 
Cycle 3 Week Cycle 4 
Week Cycle Regular Week 
Schedule 
 
 

- Glenn




"Frank W. Zammetti" <[EMAIL PROTECTED]> 
27/04/2005 04:27 PM
Please respond to
"Struts Users Mailing List" 


To
Struts Users Mailing List 
cc

Subject
Re: [OT] DOM & JavaScript
Classification








Hmm... I notice that the JSP code is referencing onMouseOver, while your 
Javascript is trying to set the attribute onmouseover... I wonder if the 
capitalization difference is an issue?  Certainly, if setAttribute() 
takes case into consideration that would do it.  You said the lines were 
identical when you looked, but could it be you glossed over the 
difference in capitalization? (I may have too).

Frank

[EMAIL PROTECTED] wrote:
> Greetings,
> 
> Once again I call on my trusted community for insight !
> I'm adding a row to a table dynamically. All is working well except for 
> one thing the Mouse events.
> 
> Here is the code for adding a row to the table.
> There is more code that adds the cells to the table (not shown).
> ...
> // Only add a row when changing the last row of the table
> if ("s"+(rowWithData) == selectId) {
> var row = table.insertRow(lastRowInTable);
> var className = "rowNormal";
> 
> if (lastRowInTable % 2 == 0) {
> className = "rowAlternate";
> }
> row.className = className;
> row.setAttribute("onmouseover", "this.className = 'hilite';");
> row.setAttribute("onmouseout", "this.className = '" + className 
+ 
> "'");
> ...
> }
> 
> 
> Here is the JSP code that creates the table row (at least one row is in 
> the page), here the mouse events are working:
>  "this.className = ''" class=" '${rowClass}'/>">
> 
> If I add an alert that dumps the innerHTML of the table after the 
> row/cells are added and I compare the two rows... 
> They are the same.
> Why are the mouse events added dynamically not recongnized ?
> 
> BTW, using IE 6.0.2900.2180.xpsp_sp2_rtm.040803-2158
> 
> TIA,
> Glenn
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Re: [OT] DOM & JavaScript

2005-04-27 Thread Frank W. Zammetti
Hmm... I notice that the JSP code is referencing onMouseOver, while your 
Javascript is trying to set the attribute onmouseover... I wonder if the 
capitalization difference is an issue?  Certainly, if setAttribute() 
takes case into consideration that would do it.  You said the lines were 
identical when you looked, but could it be you glossed over the 
difference in capitalization? (I may have too).

Frank
[EMAIL PROTECTED] wrote:
Greetings,
Once again I call on my trusted community for insight !
I'm adding a row to a table dynamically. All is working well except for 
one thing the Mouse events.

Here is the code for adding a row to the table.
There is more code that adds the cells to the table (not shown).
...
// Only add a row when changing the last row of the table
if ("s"+(rowWithData) == selectId) {
var row = table.insertRow(lastRowInTable);
var className = "rowNormal";
if (lastRowInTable % 2 == 0) {
className = "rowAlternate";
}
row.className = className;
row.setAttribute("onmouseover", "this.className = 'hilite';");
row.setAttribute("onmouseout", "this.className = '" + className + 
"'");
...
}

Here is the JSP code that creates the table row (at least one row is in 
the page), here the mouse events are working:

"this.className = ''" class="
'${rowClass}'/>">

If I add an alert that dumps the innerHTML of the table after the 
row/cells are added and I compare the two rows... 
They are the same.
Why are the mouse events added dynamically not recongnized ?

BTW, using IE 6.0.2900.2180.xpsp_sp2_rtm.040803-2158
TIA,
Glenn
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]