Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: Redimension a table on the fly?


Message #1 by walter@w... on Sun, 26 Aug 2001 23:26:02
Greetings;

I am writing a data entry application using IE5. It is typical in that 
there is a header, a schedule with an arbitrary number of entries, and a 
trailer part. It makes sense to put the schedule in a table if there is a 
way to add rows to it as new items are entered. I cannot get the following 
example, based on a TextRange object to work. Any suggestions would be 
greatly appreciated.

Thanks,

Walter Black.

<html>
<script language=javascript type="TEXT/JAVASCRIPT">
function test() {
   myTR=document.getElementsByTagName("TR")[0]
   myRange=document.body.createTextRange()
   alert("myRange.htmlText is "+myRange.htmlText)
   myRange.moveToElementText(myTR)
   alert("myRange hs been moved to "+myRange.htmlText)
   thisRange = myRange.duplicate()
   alert("thisRange.htmlText is "+thisRange.htmlText)
   myRange.collapse(true)
   myRange.pasteHTML(thisRange.htmlText) 
}	
</script>
<head>
<title>Table example</title>
</head>

<body>

<table border="1" width="100%" name="table">
  <tr>
    <td width="50%">R1C1</td>
    <td width="50%">R1C2</td>
  </tr>
  <tr>
    <td width="50%">R2C1</td>
    <td width="50%">R2C2</td>
  </tr>
</table>
<p> </p>
<button type="button" onClick=test()>Test</button>
</body>

</html>



  Return to Index