html - DOM javascript Navigation -
I want to show the hidden divCommentBody div related to the "check" checkbox, but it is not able to use javascript .
This is a Javascript function:
Function ExpandClick (state) {var TargetBaseControl = document.getElementById ("commentsTable"); Var inputs = Tarbatebase control.GetAllementsBigename ('Input'); (Var n = 0; n & lt; Inputs.length; ++ n) If (inputs [n] .type == 'checkbox' & amp; amp; input [n] .id.indexOf (' ChkBox ', 0) & gt; = 0) {if (input [n] checked) == true) {// get DivXModebody div that is related to this checkbox}}}
This markup is:
& lt; Table cellpadding = "0" limit = "0" id = "comments enabled" & gt; & Lt; Tr square = "comment" & gt; & Lt; Td square = "check the comment" & gt; & Lt; Input id = "ctl00_col2_rptComments_ctl01_chkBox" type = "checkbox" name = "ctl00 $ col2 $ rpt note $ ctl01 $ chkBox" /> & Lt; / TD & gt; & Lt; Td square = "from comment" & gt; & Lt; Span id = "ctl00_col2_rptComments_ctl01_lblUserName" title = "Posted by name" & gt; No & lt; / Span & gt; & Lt; / TD & gt; & Lt; TR & gt; & Lt; Td colspan = "100%" & gt; & Lt; Div id = "ctl00_col2_rptComments_ctl01_divCommentBody" style = "padding: 0 0 55px; display: none; background color: # E8F1F4;" & Gt; & Lt; / Div & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; Tr square = "comment" & gt; & Lt; Td square = "check the comment" & gt; & Lt; Input id = "ctl00_col2_rptComments_ctl02_chkBox" type = "checkbox" name = "ctl00 $ col2 $ rpt note $ ctl02 $ chkBox" /> & Lt; / TD & gt; & Lt; Td square = "from comment" & gt; & Lt; Span id = "ctl00_col2_rptComments_ctl02_lblUserName" title = "Posted by name" & gt; Marco & lt; / Span & gt; & Lt; / TD & gt; & Lt; TR & gt; & Lt; Td colspan = "100%" & gt; & Lt; Div id = "ctl00_col2_rptComments_ctl02_divCommentBody" style = "padding: 0 55px; display: none; background color: # E8F1F4;" & Gt; & Lt; / Div & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt;
You can get it this way:
var divId = input [n] .id.replace (/ chkBox $ /, 'divCommentBody'); Var div = document.getElementById (divId);
Comments
Post a Comment