Hi All,
I could really use some help being able to turn on or off some check boxes tucked inside a DIV. This code has worked on other forms with the same structure, but I can't seem to properly debug what's going on here. Any help is greatly appreciated. The code is below.
I could really use some help being able to turn on or off some check boxes tucked inside a DIV. This code has worked on other forms with the same structure, but I can't seem to properly debug what's going on here. Any help is greatly appreciated. The code is below.
Code:
<script>
function checkItems(item)
{
var form = document.forms[0];
var count = parseInt(document.forms[0].selcnt.value);
var nitems = parseInt(document.forms[0].numflags.value);
//
// Based upon control
// update buffer and update count
//
if (item.name.substring(0,4) == "flag")
{
if (item.checked)
count = count + 1;
else
count = count - 1;
}
document.forms[0].selcnt.value = count;
document.forms[0].submit();
return false;
}
function ItemClick(srcElement)
{
var elem;
var indx;
var pos1 = srcElement.id.indexOf("[");
var pos2 = srcElement.id.indexOf("]");
if (pos1 != -1 && pos2 != -1)
{
indx = parseInt(srcElement.id.substring(pos1+1, pos2));
i = document.forms[0].selitem.value; //previously selected selitem (record)
if (i != -1)
{
elem = document.all('trItem[' + i + ']');
if (elem)
elem.className = "item";
}
srcElement.className = "selitem";
document.forms[0].selitem.value = indx;
elem = document.all('group[' + indx + ']');
document.forms[0].action.value = "Select";
document.forms[0].selid.value = elem.value;
document.forms[0].submit();
return false;
}
}
</script>
<%
ordinals = Split(GetVal("ordinal", ""), ",", -1, 1)
%>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<TR>
<TD>
<div class="scrollTable" id="testScrollTable" style="height: 222; width: 908;">
<span class="scrollTableHead">
<table width="100%" cellspacing="0" frame="border">
<tr>
<td width="22"><nobr> </nobr></td>
<td align="center" width="50"><nobr> ID</nobr></td>
<td width="800"><nobr> Description</nobr></td>
<td width="100%"><nobr> </nobr></td>
<td></td>
</tr>
</table>
</span>
<span id="sTable" class="scrollTableBody">
<table cellspacing="0" cellpadding="0" style="border-collapse: collapse;">
<%
Set cn = GetDBConnection()
Set SQLStmt = Server.CreateObject("ADODB.Command")
Set RS = Server.CreateObject("ADODB.Recordset")
SQLStmt.CommandText = "select a.message_bkg_id, a.description, b.ordinal as ord_num, " & _
"TO_CHAR(b.ordinal, '09') AS ordinal " & _
"from message_bkg a, message_bkg_j b " & _
"where b.abbrv='" & selstation & "' and " & _
"a.message_bkg_id=b.message_bkg_id " & _
"order by ordinal"
SQLStmt.CommandType = 1
Set SQLStmt.ActiveConnection = cn
RS.Open SQLStmt
count = 0
Do While Not RS.EOF
count = count + 1
If CInt(selid) = CInt(RS("ord_num")) OR CInt(selid) = -1 Then
selid = RS("ord_num")
pos = count
seldesc = RS("description")
End If
chkd = ""
IF Not IsEmpty(ordinals) THEN
IF IsArray(ordinals) THEN
FOR EACH oid in ordinals
IF CInt(oid) = CInt(RS("ORD_NUM")) THEN
chkd = " checked"
END IF
NEXT
ELSEIF CInt(ordinals) = CInt(RS("ORD_NUM")) THEN
chkd = " checked"
END IF
END IF
%>
<tr ID="trItem[<%=count%>]" height="20" <% IF CInt(selid) = CInt(RS("ORD_NUM")) THEN %> class="selitem" <% ELSE %> class="item" <% END IF %> onClick="ItemClick(this);">
<input type="hidden" name="group[<%=count%>]" value="<%=RS("ORD_NUM")%>">
<td class="frowdata" width="22" nowrap>
<input type="checkbox" name="flag<%=count%>" id="flag<%=count%>" value="<%=RS("ORD_NUM")%>" <%=chkd%> onClick="checkItems(this);">
</td>
<td align="center" class="rowdata" width="50" nowrap> <%=RS("ORD_NUM")%></td>
<td class="lrowdata" width="800" nowrap> <%=RS("description")%></td>
<td class="ritem" width="100%" nowrap> </td>
</tr>
<%
'count = count + 1
RS.MoveNext
Loop
RS.Close
%>
<%
For row = count to 7 %>
<tr class="item" height="20">
<td class="frowdata" width="22" nowrap> </td>
<td class="rowdata" width="50" nowrap> </td>
<td class="lrowdata" width="800" nowrap> </td>
<td class="ritem" width="100%" nowrap> </td>
</tr>
<%
Next
%>
</table>
</span>
</div>