Solved

get change textbox value only

Posted on 2006-10-31
7
297 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: 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!

 
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Multi-threading long-running processes can have a significant increase in overall performance and drastically decrease over time it takes for a process to complete. Unfortunately, not all applications support native multi-threading, some by design a…
Popular third-party chat platforms like Slack, Discord, and Telegram are just a few of the many new productivity applications that are being hijacked by cybercriminals to create command-and-control (C&C) communications infrastructures for their malw…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

705 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