Hi guys, I have a web page that provides lines of text for coping. What I want to do is to have a check box at the beginning of the line and if it is checked it must select all the text in the line, but the thing is, you should be able to select more than one in a row and it must be in sequence. Also if you de-select the check box it must de-select the line. That is part one. Part two is, when I right click I can copy all the text to the clipboard but I want to add a button witch when clicked copies all the selected lines of text to the clipboard. I am not a expert in JavaScript I have multiple other languages that I code in and have only used JavaScript a few times for small stuff. This web site consists of html, css and JavaScript. function selectText(containerid) { // the variable "containerid" represents the ID of the table cell in witch the text is if (document.selection) { var range = document.body.createTextRange(); range.moveToElementText(document.getElementById(containerid)); range.select(); } else if (window.getSelection) { var range = document.createRange(); range.selectNode(document.getElementById(containerid)); window.getSelection().addRange(range); } } Code (markup): The above code allows me to select a single line of text when clicked any where in text, but I am struggling to change it to my purpose. Can any one point me in the right direction?
Okay lets eliminate part to and just focus on part 1. What I have is as follows. <html> <head> <title>MultipleSelectCheckBox</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <script type="text/javascript"> function selectText(containerid) { if (document.selection) { var range = document.body.createTextRange(); range.moveToElementText(document.getElementById(containerid)); range.select(); } else if (window.getSelection) { var range = document.createRange(); range.selectNode(document.getElementById(containerid)); window.getSelection().addRange(range); } } </script> <script type="text/javascript"> function OnChangeCheckbox (checkbox, containerid) { if (checkbox.checked) { selectText(containerid); } else { } } </script> <table> <tr><td id="myTd1"><input type="checkbox" onclick="OnChangeCheckbox (this, 'myTd1');" id="myCheckbox1" />Sample check box<br/></td></tr> <tr><td id="myTd2"><input type="checkbox" onclick="OnChangeCheckbox (this, 'myTd2');" id="myCheckbox2" />Sample check box<br/></td></tr> <tr><td id="myTd3"><input type="checkbox" onclick="OnChangeCheckbox (this, 'myTd3');" id="myCheckbox3" />Sample check box<br/></td></tr> <tr><td id="myTd4"><input type="checkbox" onclick="OnChangeCheckbox (this, 'myTd4');" id="myCheckbox4" />Sample check box<br/></td></tr> <tr><td id="myTd5"><input type="checkbox" onclick="OnChangeCheckbox (this, 'myTd5');" id="myCheckbox5" />Sample check box<br/></td></tr> </table> </body> </html> Code (markup): What it does is when you click a check box it highlights the table cell witch is correct and if I check the check box directly under the one I checked first it selects that cell also, but when I want to skip one It does not highlight the next one checked. I must first check the ones in between and then re-check that one before it selects it, Also does any body know how to de-select the cell when the check box is unchecked.