• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

get change textbox value only

Hi

I have a senario where I am try to get values from 100 records and each record has 10 columns (10 values).
form look like grid layout with 10 columns and 100 rows.
Problem is when values are retrived and displayed in the form most of them are null. and user will update the values from the form.
Everytime when user clicks on update 100 records will be getting updated. but let say user changes only 2 records(rows) and clicks on update it will send 100 records(1000 values to database) and number of changes 2 records(20 values).
This will make process slow.
My question is there anyway I can save only the changed values and update the records insted of sending all values.

capture changes and update database.

Thanks
0
basirana
Asked:
basirana
1 Solution
 
owenli27Commented:
You may need to implement AJAX into your code.  There are demo and some sample codes at this links  http://ajaxtags.no-ip.info/  
You also can easily find other AJAX Sample applications on Web.
0
 
jaggernatCommented:
>>>>. but let say user changes only 2 records(rows) and clicks on update it will send 100 records

Change the backend logic .i.e. once the user changes(updates) the fields in front-end, in the database, update  only those fields which were Changed in front-end. Those fields which were not changed , should not be updated in database.
0
 
KuldeepchaturvediCommented:
you can use a hidden form field on every record and then use java script to update this value when user changes anything on the record.
at the back end you can check this hidden field to determine which records needs updation in the database...
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jaggernatCommented:
true, just like setting a flag for the field!
0
 
KuldeepchaturvediCommented:
:-) I have used this trick more than I can care to remember.
0
 
basiranaAuthor Commented:
Can I get example how can capture changes
0
 
KuldeepchaturvediCommented:
on your display jsp....
add another hidden input parameter in your table...

i.e.
if you have
<TR>
<TD>data1</TD><TD>Data2</TD>...... add <TD><input type=hidden name="sw<%=i%>" value="0"></TD>
//here I am assuming that your table is getting created in some kind of loop & i is the counter of the loop.

now on every element you will have to add this script "onChange=setSw('sw<%=i%>');

write a small javascript function

function setSw ( switch)
{
document.getElementbyId(switch).value="1";
}

now in your back end code...

for(int i=0; i<100; i++)
{
if(request.getParameter("sw"+i).equals("1")
{
//need to update this row..
}
else
{
// skip the row..
}
}
}

there are other ways of accomplishing the same thing.. I have tried to put in the most basic approach.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now