adding rows without reloading the page 
Author Message
 adding rows without reloading the page

howz it goin,

One of my friends told me that it was possible to add new rows to a table
and show them without actually reloading the page using VBScript. Is this
possible? if yes, can anyone give me some sample codes or some hints.

cheers

--
suman
Website Design and Multimedia
http://www.*-*-*.com/



Sun, 14 Nov 2004 13:25:14 GMT  
 adding rows without reloading the page
Sure,

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
 <title>Test</title>
    <script language="VBScript">
      Sub cmdAdd_OnClick()
        Dim objNewRow, objNewCell

        Set objNewRow = TestTable.insertRow(TestTable.Rows.Length - 1)
        Set objNewCell = objNewRow.insertCell

        objNewCell.innerHTML = "Row " & TestTable.Rows.Length - 1
      End Sub
    </script>
</head>

<body>

<table id="TestTable">
  <tr><td>Row 1</td></tr>
  <tr><td>Row 2</td></tr>
  <tr><td><input type="button" name="cmdAdd" value="Add Row"></td></tr>
</table>

</body>
</html>

Hope this helps!

Mythran



Sun, 14 Nov 2004 13:47:50 GMT  
 adding rows without reloading the page
Of course you know, this will only work in IE.


Quote:
> Sure,

> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

> <html>
> <head>
>  <title>Test</title>
>     <script language="VBScript">
>       Sub cmdAdd_OnClick()
>         Dim objNewRow, objNewCell

>         Set objNewRow = TestTable.insertRow(TestTable.Rows.Length - 1)
>         Set objNewCell = objNewRow.insertCell

>         objNewCell.innerHTML = "Row " & TestTable.Rows.Length - 1
>       End Sub
>     </script>
> </head>

> <body>

> <table id="TestTable">
>   <tr><td>Row 1</td></tr>
>   <tr><td>Row 2</td></tr>
>   <tr><td><input type="button" name="cmdAdd" value="Add Row"></td></tr>
> </table>

> </body>
> </html>

> Hope this helps!

> Mythran



Sun, 14 Nov 2004 20:21:42 GMT  
 adding rows without reloading the page
So, you want a cross-browser version?  Well...here ya go:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
 <title>Test</title>
    <script language="JavaScript">
      function cmdAdd_OnClick()
      {
        var objNewRow, objNewCell;

        objNewRow = TestTable.insertRow(TestTable.rows.length - 1);
        objNewCell = objNewRow.insertCell();

        objNewCell.innerHTML = "Row " + (TestTable.rows.length - 1);
      }
    </script>
</head>

<body>

<table id="TestTable">
  <tr><td>Row 1</td></tr>
  <tr><td>Row 2</td></tr>
  <tr><td>
  <input type="button" name="cmdAdd" value="Add Row"
    onclick="JavaScript:cmdAdd_OnClick();">
  </td></tr>
</table>

</body>
</html>

Same thing as before, just replaced a few things to make it JavaScript :)

Mythran



Mon, 15 Nov 2004 06:23:16 GMT  
 adding rows without reloading the page
Changing the script to JavaScript is not enough to make this cross-browser compatible.
--

Bill James
Microsoft MVPDTS

Win9x VBScript Utilities ? www.billsway.com/vbspage/
Windows Tweaks & Tips ? www.billsway.com/notes_public/

Quote:

> So, you want a cross-browser version?  Well...here ya go:

> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

> <html>
> <head>
>  <title>Test</title>
>     <script language="JavaScript">
>       function cmdAdd_OnClick()
>       {
>         var objNewRow, objNewCell;

>         objNewRow = TestTable.insertRow(TestTable.rows.length - 1);
>         objNewCell = objNewRow.insertCell();

>         objNewCell.innerHTML = "Row " + (TestTable.rows.length - 1);
>       }
>     </script>
> </head>

> <body>

> <table id="TestTable">
>   <tr><td>Row 1</td></tr>
>   <tr><td>Row 2</td></tr>
>   <tr><td>
>   <input type="button" name="cmdAdd" value="Add Row"
>     onclick="JavaScript:cmdAdd_OnClick();">
>   </td></tr>
> </table>

> </body>
> </html>

> Same thing as before, just replaced a few things to make it JavaScript :)

> Mythran



Mon, 15 Nov 2004 06:42:58 GMT  
 adding rows without reloading the page
:: So, you want a cross-browser version?  Well...here ya go:
::

 insertRow and insertCell are IE specific...

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Mon, 15 Nov 2004 09:07:26 GMT  
 adding rows without reloading the page
Well, well, always have to make things harder...well then...

Umm..maybe I should install Netscape then heh...anywho, according to
Microsoft's website (unless I am wrong again), the method's that were used
are part of the DHTML heirarchy.  Why is it not part of other browser's as
well if this were true?  Otherwise, I am mistaken and I withrdraw my feeble
attempt at cross browsing :P

Thanks for the update Michael and Bill....

Mythran



Mon, 15 Nov 2004 10:55:39 GMT  
 adding rows without reloading the page
So I guess this goes on my list of :
"Interesting stuff I cannot use because my boss absolutely wants the site to
work on IE and Netscape".


Quote:
> Well, well, always have to make things harder...well then...

> Umm..maybe I should install Netscape then heh...anywho, according to
> Microsoft's website (unless I am wrong again), the method's that were used
> are part of the DHTML heirarchy.  Why is it not part of other browser's as
> well if this were true?  Otherwise, I am mistaken and I withrdraw my
feeble
> attempt at cross browsing :P

> Thanks for the update Michael and Bill....

> Mythran



Mon, 15 Nov 2004 21:00:43 GMT  
 adding rows without reloading the page
Pretty much sums it up.   While IE has a lot of nifty functionality, it's
not the only browser out there.  A lot of IE-only functions are broken or
display complete gibberish on other browsers.


Quote:
> So I guess this goes on my list of :
> "Interesting stuff I cannot use because my boss absolutely wants the site
to
> work on IE and Netscape".



Tue, 16 Nov 2004 00:00:56 GMT  
 adding rows without reloading the page
Thank you,

is there any way i can delete these rows using a delete button

cheers
suman

---


Quote:
> Sure,

> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

> <html>
> <head>
>  <title>Test</title>
>     <script language="VBScript">
>       Sub cmdAdd_OnClick()
>         Dim objNewRow, objNewCell

>         Set objNewRow = TestTable.insertRow(TestTable.Rows.Length - 1)
>         Set objNewCell = objNewRow.insertCell

>         objNewCell.innerHTML = "Row " & TestTable.Rows.Length - 1
>       End Sub
>     </script>
> </head>

> <body>

> <table id="TestTable">
>   <tr><td>Row 1</td></tr>
>   <tr><td>Row 2</td></tr>
>   <tr><td><input type="button" name="cmdAdd" value="Add Row"></td></tr>
> </table>

> </body>
> </html>

> Hope this helps!

> Mythran



Fri, 19 Nov 2004 13:13:43 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. adding a table row, without setting same defaults as previous row

2. Add row to datatable from datagrid without leaving current row with cursor

3. Data access without reloading page

4. Populating a second list box depending on the results of the first, without reloading ASP page

5. Sending data between open pages without reloading

6. Row jumps to next page when adding line

7. Reload registry without quiting IE?

8. row heights of table rows added by vba

9. Add Button to a row by row data display

10. Reload of pages in DotNet

11. Page Reloading

12. How to reload WWW page by Activex

 

 
Powered by phpBB® Forum Software