473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Add Row in Grid using Javascript...

Hi,

i have a grid / table in html form as followings code,:-


Expand|Select|Wrap|Line Numbers
  1.     function addCritr(curno){
  2.         var f = document.frmC5W002;
  3.  
  4.         // check val 1 & val 2 range
  5.         if (f.txt_val1.value!="" && f.txt_val2.value!=""){
  6.             if(parseInt(f.txt_val2.value)<=parseInt(f.txt_val1.value)){
  7.                 alert("Value 2 cannot be less than Value 1!")
  8.                 f.txt_val2.focus();
  9.                 return;
  10.             }
  11.         }
  12.         curno = curno + 1;
  13.         var grid = document.getElementById("CritrGrid");
  14.         var numRows = grid.rows.length; 
  15.  
  16.         grid.insertRow(curno);
  17.         grid.rows[curno].insertCell(0);
  18.         grid.rows[curno].insertCell(1);
  19.  
  20.         grid.rows[curno].cells[0].innerHTML = "<IMG SRC='../image/plussign.gif' onmouseover=this.style.cursor='hand' onclick='addCritr("+curno+")'>";
  21.  
  22.         grid.rows[curno].cells[1].innerText =  curno;
  23.  
  24. }
  25.  
  26.  
[HTML]<HTML>
<TABLE cellspacing="1" cellpadding="1" id="CritrGrid" class="grid" ALIGN="center" width="95%">
<THEAD class="header">
<TH width="2%">&nbsp;</TH>
<TH width="3%">SEQ</TH>
</THEAD>
<TR>
<TD>
<IMG SRC="../image/plussign.gif" onmouseover=this.style.cursor='hand' onclick="addCritr(1);">
</TD>
<TD>1</TD>
</TR>
</HTML>

[/HTML]
After i'd click on the "plussign.gif", it will call the function "addCritr()", and add 1 more row in grid "CritrGrid" using javascript (grid.rows[curno].insertCell(0); follow by grid.rows[curno].cells[0]....) ..

My question is after i'd add so many rows on the grid, and after i refresh the web page, all of the rows that i added using the javascript function will be become blank again..

how would i keep those rows & values after refresh the web page???


Anyone know bout these? Pls help!!!!~

Many Thanks ;-))
Jan 25 '08 #1
3 3014
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

You will need to use cookies to save the number of rows added and then when the page loads, add the number of rows that have been saved in the cookies. Read about cookies here.
Jan 25 '08 #2
Welcome to TSDN!

You will need to use cookies to save the number of rows added and then when the page loads, add the number of rows that have been saved in the cookies. Read about cookies here.


in this case, cookies really can work ..
but it have d limitation also.. because cookies file size got limit, for eg : IE can store up to 4096 bytes file size in a cookies file.

is there any way to increase / limit d cookies file size?
Jan 29 '08 #3
acoder
16,027 Expert Mod 8TB
in this case, cookies really can work ..
but it have d limitation also.. because cookies file size got limit, for eg : IE can store up to 4096 bytes file size in a cookies file.

is there any way to increase / limit d cookies file size?
It can work because you only need to save the minimum information required to reconstruct the table again, e.g. no need to save the img string information because that is repeated for each row.
Jan 29 '08 #4

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

Similar topics

6
by: Kate | last post by:
Hi, we are now developing complex business application using Ajax framework. Could anyone point me to the editable javascript grid control which supports XML loading. Good javascript API would be...
1
by: Steve | last post by:
Hi I have a db with 2 tables that I want to bind to a grid depending on a selection in a Dropdownlist Also I want to be able to select a row from the gris to fill some textboxes. The databases...
1
by: Nikhil Patel | last post by:
Hi all, I have written an ASP.Net form that displays a sortable grid. I works fine in Internet Explorer. But it gives me an error when I try to display it in 3rd party application. The error says...
10
by: kaczmar2 | last post by:
Hey there, I have a large image in a browser window, and I would like a way to overlay grid lines on top of the image, so a user can show the grid or hide the grid lines. The grid would cover...
0
by: Kaushik Gadani | last post by:
I am using VB as code behind of ASP.Net (Framework 1.1) I want to call grid's edit command through javascript. This requirements comes, when I want to facilitate user to call edit command by...
6
by: Romulo NF | last post by:
Greetings again to everyone, Im back to show this grid componenet i´ve developed. With this grid you can show the data like a normal table, remove the rows that you need, add rows, import data,...
2
by: mdock | last post by:
Hello, I have a javascript grid on my ASP page which displays information about the history of specific units produced in our manufacturing facility. One of the results is the order number on...
5
by: gaya3 | last post by:
Hi, can anyone find error in the following example <%@ include file="JspBean.jsp" %> <%@ page import="java.util.*"%> <html> <head> <%
3
by: amitjain123 | last post by:
Hi All, I need one solution. I have list box and grid view on screen. I want to add selected item of list box into grid view as row. Using javascript. Can we do this? Is any alternative...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.