ordered sublist

(How) Is it possible to write HTML-code that results in the following
ordered list (without 'hardcoding' the numbers) ?

1. First Item
    1.1. First Subitem of First Item
    1.2. Second Subitem of First Item
    1.3. Third Subitem of First Item
2. Second Item
    2.1. First SubItem of First Item
    2.2. Second Subitem of Second Item

Ann_Van_EykenAsked:
Who is Participating?
 
mblaseConnect With a Mentor Commented:
You can't in HTML, to be sure. The closest solution would use two nested <OL> sets, and look like this:

<OL>
<LI>First Item
    <OL>
    <LI>First Subitem of First Item
    <LI>Second Subitem of First Item
    <LI>Third Subitem of First Item
    </OL>
<LI>Second Item
    <OL>
    <LI>First SubItem of First Item
    <LI>Second Subitem of Second Item
    </OL>
</OL>

Maybe we could cobble a JavaScript solution? It'd be ugly, but it would work --

<SCRIPT LANGUAGE="JavaScript">
<!--
var mc = 0;    // main counter
var sc = 0;    // sub counter
function mcount() { mc++; document.write(mc+". "); }
function scount() { sc++; document.write(mc+"."+sc+". "); }
//-->
</SCRIPT>

<DL>
<DT><SCRIPT LANGUAGE="JavaScript">mcount()</SCRIPT>First Item
    <DD><SCRIPT LANGUAGE="JavaScript">scount()</SCRIPT>First Subitem of First Item
    <DD><SCRIPT LANGUAGE="JavaScript">scount()</SCRIPT>Second Subitem of First Item
    <DD><SCRIPT LANGUAGE="JavaScript">scount()</SCRIPT>Third Subitem of First Item
<DT><SCRIPT LANGUAGE="JavaScript">mcount()</SCRIPT>Second Item
    <DD><SCRIPT LANGUAGE="JavaScript">scount()</SCRIPT>First SubItem of First Item
    <DD><SCRIPT LANGUAGE="JavaScript">scount()</SCRIPT>Second Subitem of Second Item
</DL>
0
 
mark2150Commented:
I'd like to know too...

M
0
 
PiNCommented:
I'm afraid, you can't ;-)
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
PiNCommented:
Funny idea mblase...pretty close to the request...
Congrats !(didn't think of that way)
0
 
mblaseCommented:
Actually, that doesn't *quite* do what Ann wanted. Here's the line to modify:

function mcount() { mc++; sc=0; document.write(mc+". "); }

Before it counted 1, 1.1, 1.2, 2, 2.3, 2.4... instead of 2, 2.1, 2.2, as desired. This will correct that.
0
 
mblaseCommented:
Oh, and if you want to make the code a little cleaner, you should be able to eliminate LANGUAGE="JavaScript" from all the <SCRIPT> tags, since all browsers should default to JavaScript as the scripting language to use.
0
All Courses

From novice to tech pro — start learning today.