Js 如何把数据变成级联结构数据

JavaScript013

Js 如何把数据变成级联结构数据,第1张

这里提下数据结构中级联数据怎么建立

1.名称 name

2.键值 key

3.父级 fatherId (如果有就填父级id,没有就是null)

4.级联路径 path (他是父级+当前级别,ex:0-1-,父级就是0,当前级别就是-,这样目的就是为了上级查询)

这样的话干脆就用radio,别用checkbox,你看这样行不

<table width="48%" height="144" border="0" cellpadding="0" cellspacing="0">

<tr>

<td rowspan="2"><input name="shallday" type="radio" class="formfield3" id="shallday" value="1" checked onclick="document.getElementById('span1').style.visibility='visible'document.getElementById('span2').style.visibility='visible'"/>

A </td>

<td><span id="span1"><input name="shallday2" type="radio" class="formfield3" id="shallday2" value="1" checked/>

a</span></td>

</tr>

<tr>

<td><span id="span2"><input name="shallday2" type="radio" class="formfield3" id="shallday3" value="1" />

b</span></td>

</tr>

<tr>

<td><input name="shallday" type="radio" class="formfield3" id="shallday4" value="1" onclick="document.getElementById('span1').style.visibility='hidden'document.getElementById('span2').style.visibility='hidden'"/>

B</td>

<td></td>

</tr>

</table>