Author |
Message |
Suman Daha #1 / 10
|
 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 |
|
 |
Mythra #2 / 10
|
 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 |
|
 |
Rayda #3 / 10
|
 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 |
|
 |
Mythra #4 / 10
|
 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 |
|
 |
Bill Jame #5 / 10
|
 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 |
|
 |
MVP #6 / 10
|
 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 |
|
 |
Mythra #7 / 10
|
 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 |
|
 |
Rayda #8 / 10
|
 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 |
|
 |
Ned Flander #9 / 10
|
 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 |
|
 |
Suman Daha #10 / 10
|
 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 |
|
|