Re: Passing div object id's to functions
by Eric Anderson <eric_anderson(at)hrsoft.com>
|
Date: |
Wed, 11 Oct 2000 12:24:14 -0500 |
To: |
"John Murray" <jmnc(at)lis.net.au>, <hwg-techniques(at)hwg.org> |
In-Reply-To: |
opalintel |
|
todo: View
Thread,
Original
|
|
Hi John!
Looking at your code, try putting the following inside your alertthez()
function:
var zI;
zI = eval(divid + ".style.zIndex");
alert(zI);
Since you are passing in 'fred', the function receives a string instead of
an object and thus requires the eval() function to translate that string to
a proper object. You may have to qualify the string in the eval() function
with "document.all." for IE and "document." for NN (I don't know for
certain).
You could also try changing the function call to
onClick="alertthez(this);"
in hopes that the browswer will pass the DIV object into the
function. Then you wouldn't have to change the function contents at all.
Hope this helps,
Eric
At 04:19 PM 10/11/2000 +1000, John Murray wrote:
>I know I'm missing something simple, and probably being lazy, but I start
>from the perspective that the guys who set up DHTML would know we would want
>to do this.
>#####################
<html>
<head>
<style>
.thedivs {
color:"#ffffff";
}
</style>
<script type="text/javascript">
var divid;
function alertthez(divid){
alert(divid.style.zIndex);
}
</script>
<body>
<div id="fred" style="color:"#333333" onClick="alertthez('fred');">
blah blah
</div>
</body>
</html>
>###################
>yet it falls over with "style.zIndex is not an object"
>
>It is so fundamentally necessary that there must be some syntax to pass the
>id value into the function. What am I mising?
>
>John
HWG hwg-techniques mailing list archives,
maintained by Webmasters @ IWA