Solved

get change textbox value only

Posted on 2006-10-31
7
288 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
ID: 17842198
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
ID: 17843117
>>>>. 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
ID: 17844533
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 10

Expert Comment

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

Expert Comment

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

Author Comment

by:basirana
ID: 17845041
Can I get example how can capture changes
0
 
LVL 19

Accepted Solution

by:
Kuldeepchaturvedi earned 500 total points
ID: 17849383
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The new Gmail Phishing Scam going around is surprising even the savviest of users with its sophisticated techniques. This attack comes as a nightmare trifecta for email filtering services; sent from a familiar contact, using authentic tone and verbi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

22 Experts available now in Live!

Get 1:1 Help Now