Solved

get change textbox value only

Posted on 2006-10-31
7
287 Views
Last Modified: 2010-04-01
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
Comment
Question by:basirana
7 Comments
 
LVL 9

Expert Comment

by:owenli27
Comment Utility
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
 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
>>>>. 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
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 10

Expert Comment

by:jaggernat
Comment Utility
true, just like setting a flag for the field!
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
Comment Utility
:-) I have used this trick more than I can care to remember.
0
 

Author Comment

by:basirana
Comment Utility
Can I get example how can capture changes
0
 
LVL 19

Accepted Solution

by:
Kuldeepchaturvedi earned 500 total points
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

HOW TO: Upload an ISO image to a VMware datastore for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere Host Client, and checking its MD5 checksum signature is correct.  It's a good idea to compare checksums, because many installat…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now