By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,843 Members | 2,311 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,843 IT Pros & Developers. It's quick & easy.

How to handle ondrag event in TD ?

P: 4
I have a table.

Expand|Select|Wrap|Line Numbers
  1.  <table border=1> 
  2. <tr>
  3. <td onmousedown="create(this)"></td>
  4. <td onmousedown="create(this)"></td>
  5. </tr>
  6. <tr>
  7. <td onmousedown="create(this)"></td>
  8. <td onmousedown="create(this)"></td>
  9. </tr>
  10. </table>
  11. <script language="javascript">
  12. function create(obj)
  13. {
  14. if(obj.hasChildNodes()) {
  15. value = obj.firstChild.nodeValue;
  16. }
  17. var children = obj.childNodes;
  18. for(k=0; k<children.length; k++) {
  19. obj.removeChild(children.item(k));
  20. }
  21. var value = "";
  22. var x = obj.createElement("input");
  23. obj.type = "text";
  24. obj.value = value;
  25. obj.focus();
  26. }
  27. </script>
This is my actual script. It will create a textbox in the mousedown event of <td>.

Now my question is, How can I select the four <td>s, whether in the same onmousedown event or there is any onmousedrag event? please help...

If I select any one of the <td>, its border should be highlighted.
And also If I select all the <td>s, its outer border should be highlighted.
Is it possible in javascript? Similar to MS Excel.

I hope anyone of u people reply my question.

Sep 29 '05 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 100+
P: 2,327
I pasted your code into a html file and tried it in a browser. I can't get any action out of it. All that happens is a small grey box shows up.

Are you looking for a 2x2 table? When you click on one of the cells it should be highlighted. If you drag and select all of the boxes, all of them should be highlighted (much like excel)?
Nov 18 '05 #2

P: 1
Hi , Suresh did u manage to find the solution
for highlight a row when on click and keep it highlighted until you let go of the
Mar 29 '06 #3

Expert Mod 15k+
P: 16,027

Post your reply

Sign in to post your reply or Sign up for a free account.