sonicred Posted November 19, 2010 Share Posted November 19, 2010 child = "form[check11][]"brother= <label>father =<td>end result: get the info from label.HiAt the moment i used document.getElementsByName('form[check11][]') .I can't use document.getElementById because the id sometime it's check11, order time check110 etc..It's not safe to use for me..Is is there a way that i can get from "form[check11][]" to the label.innerHTML because i need the xxxx <tr class="form-block form-block-check11"> <td> <input name="form[check11][]" value="790" id="check110" type="checkbox"> <label for="check110">xxxxxx</label> <div class="formClr"></div><span id="component4012" class="formNoError">Invalid Input</span> </td></tr> p.s i bypass it and found a other solution: for(j=0;j<_idx2;j++) {var parmId = document.getElementsByName('form['+param+'][]').getAttribute('id'); if(document.getElementsByTagName('label')[j].getAttribute('for') == parmId ) {checklist += document.getElementsByTagName('label')[j].innerHTML ;but still i wonder if it can be diffrent and beter.. Link to comment Share on other sites More sharing options...
ShadowMage Posted November 19, 2010 Share Posted November 19, 2010 How about nextSibling()? Link to comment Share on other sites More sharing options...
jeffman Posted November 19, 2010 Share Posted November 19, 2010 The trick, as the tutorial shows, is to skip over the text nodes that contain your tabs and line breaks. nextElementSibling will do that, but it is not universally supported (and won't be for a while, considering the half-life of legacy browsers). Link to comment Share on other sites More sharing options...
sonicred Posted December 1, 2010 Author Share Posted December 1, 2010 hii did read both but i don't understand it..is there a better example?gr Link to comment Share on other sites More sharing options...
ShadowMage Posted December 1, 2010 Share Posted December 1, 2010 See if you can figure it out using my example. All I did was take the Try-it example for nextSibling and modify it to look like an html document. <html><head><script type="text/javascript">//check if the next sibling node is an element nodefunction get_nextsibling(n) { x=n.nextSibling; while (x.nodeType!=1) { x=x.nextSibling; } return x;}function siblingTest(el) { var container = document.getElementById("container"); var str = "Start at: "+el.nodeName; var sibling = get_nextsibling(el); str += "<br />Next sibling: "+sibling.nodeName; container.innerHTML = str;}</script></head><body><div style='border: 1px solid'> <input type='button' value='Find Sibling' onclick='siblingTest(this);' /> <span>This is a span</span> <div id='container'></div></div></body></html> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.