Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving Value property of <LI> element in DHTML

Status
Not open for further replies.

muesli

Programmer
Dec 12, 2001
71
GB
I'm writing an IE6.0 application where it is necessary to cross-reference footnote markers in text with the footnotes, shown as items in an ordered list. Has anyone found an easy way of getting value of the number next to the list item for future reference? the Value proeprty just returns 0.
 
i'm not sure i know what you mean...do you want the text inside the <li> tag? if so this should work:

<li id=&quot;li1&quot;>text</li>

<script>
document.getElementById('li1').innerHTML
</script>



 
No, sorry. Having created the list item, I'm trying to find out what number the browser has assigned to it, i.e. 1, 2, 3 or even i, ii, iii, iv etc. I need to dynamically add footnotes in my app, and update the corresponding numbers in the body of the text. It is a pain.
 
<div id=&quot;divid&quot;>
x number of <li> tags
</div>

<script language=&quot;javascript&quot; type=&quot;text/javascript&quot;>
var tag;
tag = document.getElementById('divid').getElementsByTagName('li');

// tag is a arrays of all li inside call the last one like this
tag[tag.length - 1] ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
Thanks, but how, given the actual object itself, do I find out what its list number marker is?
 
is the content always the came ?
if so can u give me the content of this wanted <li> ? ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
say something along the lines of
<OL>
<LI> This is the first footnote</LI>
<LI> This is the second footnote</LI>
</OL>

would give

1. This is the first footnote
2. This is the second footnote

It's the '1' and the '2' for the respective items is what I'm after.
 
<html><head>
<script language=&quot;javascript&quot; type=&quot;text/javascript&quot;>
function is_this_what_u_want() {
var tag;
tag = document.getElementById('divid').getElementsByTagName('li');
// remember 0 call the 1st element and so on
// so now &quot;This is the first footnote&quot; is the tag[0]
// lets append to hit for fun
tag[0].appendChild(document.createTextNode(' plus this text lol'));
}
</script>
</head><body>
<div id=divid>
<OL>
<LI> This is the first footnote</LI>
<LI> This is the second footnote</LI>
</OL>
</div>
<a href=&quot;javascript:is_this_what_u_want()&quot;>test it</a>
</body></html> ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top