拖放后列出填充的TD ID(+内容) [英] listing populated TD IDs (+ contents) after drag-drop
问题描述
大家好,
我有一个表可以放入一组克隆复选框(使用scriptabulous)。有人可以告诉我如何获取所有填充单元格的列表,以及每个单元格中的复选框(wuth它们动态分配的值)。例如:
cell 5 =>条件2选择=> box1,box3选中
cell 9 =>条件1选择=> box4 check
PS:以下是我的代码的相关(?)片段。
谢谢!
表(目标)
[HTML]< table style =" text-align:center;" border =" 2"
cellpadding =" 2" cellspacing =" 2">
< tbody>
< tr>
< td style =" width :150px;身高:100px;">
< div id =" cell1"> A1< br>
空< / div>
< / td>
< td style =" width:150px;身高:100px;">
< div id =" cell2"> A2< br>
空< / div>
< / td>
< / tr>
< tr>
< td style =" width:150px ;高度:100px;">
< div id =" cell3"> B1< br>
空< / div>
< / td>
< td style =" width:150px;身高:100px;">
< div id =" cell4"> B2< br>
空< / div>
< / td>
< / tr>
< / tbody>
< / table>
[/ HTML]
可疑的复杂文件
[HTML]< div id =" l1">
< select name =" conditions_list" ID = QUOT; selectField" onChange =" updateValue();">
< option value ="">< / option>
< option value =" ; 1"> 1< / option>
< option value =" 2"> 2< / option>
< option value =" 3" ;> 3< / option>
< option value =" 4"> 4< / option>
< / select>
< br>
< span class =" style1">
< span class =" style5">
< span style =" color:rgb(255,0,0);"> BOX1< / span>
< input id =" box1"名称= QUOT; BOX1 []"值= QUOT;" type =" checkbox">
< span style =" color:rgb(255,0,0);"> BOX2< / span>
< input id =" box2"名称= QUOT; BOX2 []"值= QUOT;" type =" checkbox">< br>
< span style =" color:rgb(255,0,0);"> BOX3< / span>
< input id =" box3"名称= QUOT; BOX3 []"值= QUOT;" type =" checkbox">
< span style =" color:rgb(255,0,0);"> BOX4< / span>
< input id =" box4"名称= QUOT; box4 []"值= QUOT;" type =" checkbox">
< / span>
< / span>
< / div> [/ HTML ]
获取特定单元格中的复选框:
展开 | 选择 | 换行 | 行号
谢谢acoder回复。
因为我是JS的新手,我会问几个问题,所以我理解如何继续这个(我还是有点困惑)使用JS语法):
1)document.getElementById(cellID)的CellID部分我假设是一个变量,引用每个TD(或我的代码中的DIV)的ID。如果是这样,我是否需要为box1做一个循环。通过box4 (即方框
i)。
2)我假设我需要类似if(document.getElementById(''box
Hi all,
I have a table to which an array of cloned checkboxes can be dropped in (using scriptabulous). Could someone please tell me how I can get a list of all populated cells, and which checkboxes within each cell are checked (wuth their dynamically assigned values). For example:
cell 5 => condition 2 selected => box1, box3 checked
cell 9 => condition 1 selected => box4 checked
P.S: Below are relevant(?) snippets of my code.
Thanks!
TABLE (THE TARGET)
[HTML]<table style="text-align: center;" border="2"
cellpadding="2" cellspacing="2"">
<tbody>
<tr>
<td style="width: 150px; height: 100px;">
<div id="cell1">A1<br>
Empty</div>
</td>
<td style="width: 150px; height: 100px;">
<div id="cell2">A2<br>
Empty</div>
</td>
</tr>
<tr>
<td style="width: 150px; height: 100px;">
<div id="cell3">B1<br>
Empty</div>
</td>
<td style="width: 150px; height: 100px;">
<div id="cell4">B2<br>
Empty</div>
</td>
</tr>
</tbody>
</table>
[/HTML]
DRAGGABLE CHECKBOXES
[HTML]<div id="l1">
<select name="conditions_list" id="selectField" onChange="updateValue();">
<option value=""></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<br>
<span class="style1">
<span class="style5">
<span style="color: rgb(255, 0, 0);">BOX1</span>
<input id="box1" name="box1[]" value="" type="checkbox">
<span style="color: rgb(255, 0, 0);">BOX2</span>
<input id="box2" name="box2[]" value="" type="checkbox"><br>
<span style="color: rgb(255, 0, 0);">BOX3</span>
<input id="box3" name="box3[]" value="" type="checkbox">
<span style="color: rgb(255, 0, 0);">BOX4</span>
<input id="box4" name="box4[]" value="" type="checkbox">
</span>
</span>
</div>[/HTML]解决方案To get the checkboxes in a particular cell:
Expand|Select|Wrap|Line Numbers
Thank you "acoder" for the reply.
Since I''m a JS newbie, I''ll ask a few questions so I understand how to follow on from this (I''m still a bit confused with JS syntax):
1) The CellID part of "document.getElementById(cellID)" I assume is a variable refering to the ID of each TD (or DIV in my code). If so, do I need to make a loop for "box1" through "box4" (i.e., box
i).
2) I assume I need something like "if (document.getElementById(''box
这篇关于拖放后列出填充的TD ID(+内容)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文