473,378 Members | 1,542 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,378 software developers and data experts.

How do I get form elements values BEFORE SUBMIT & AFTER SUBMIT????

Hi All,
Here is the reason why i ak asking for ur help.

I have a edit form in which the values already stored in DB are
populated.
User can edit some or all the values in the form.
then he submit the form.

NOW I WANT SOME JAVASCRIPT / PHP FUNCTIONALITY WHICH WILL GIVE ME THE
types & values OF ALL ELEMENTS ON FORM WHICH SHOULD BE before
submitting & after submitting.
I HAVE TO COMPARE these values so that i can send only changed values
to server.

I HAD TRIED form.elements in JAVASCRIPT BUT IT GIVES SAME VALUES.

Regards,
Rider
Nov 18 '08 #1
5 10292
Rider schreef:
Hi All,
Here is the reason why i ak asking for ur help.
Hi,
>
I have a edit form in which the values already stored in DB are
populated.
User can edit some or all the values in the form.
then he submit the form.

NOW I WANT SOME JAVASCRIPT / PHP FUNCTIONALITY WHICH WILL GIVE ME THE
types & values OF ALL ELEMENTS ON FORM WHICH SHOULD BE before
submitting & after submitting.
Which should be WHAT?

I HAVE TO COMPARE these values so that i can send only changed values
to server.
If you want to do that before submitting, you need a JavaScript solution.
And why don't you take the whole form, and update all posted? Why do you
want to 'flag' the elements that are changed?

I HAD TRIED form.elements in JAVASCRIPT BUT IT GIVES SAME VALUES.
???
Form.elements is not valid since you didn't name the form which you are
addressing.

You need to start with:
document.forms["formnamehere"].elements etc.

But this has nothing to do with PHP.
You must learn how: HTML and forms work and how different formelements
(eg text, radio, checkbox, select, etc) are addressed from JavaScript.

For JavaScript questions you better post here: comp.lang.javascript

Good luck.

Regards,
Erwin Moller
>
Regards,
Rider

--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
Nov 18 '08 #2
Rider wrote:
I have a edit form in which the values already stored in DB are
populated.
User can edit some or all the values in the form.
then he submit the form.

NOW I WANT SOME JAVASCRIPT / PHP FUNCTIONALITY WHICH WILL GIVE ME THE
types & values OF ALL ELEMENTS ON FORM WHICH SHOULD BE before
submitting & after submitting.
I HAVE TO COMPARE these values so that i can send only changed values
to server.

I HAD TRIED form.elements in JAVASCRIPT BUT IT GIVES SAME VALUES.
First of all: Your problem is not more important only because you use more
than one question mark or write in capital letters.

$valuesFromDB = ...;
$valuesFromForm = $_POST;

foreach ($valuesFromForm as $key =$value) {
if ($value != $valuesFromDB[$key]) {
// value with key $key changed
}
}
Sven Reuter
--
http://www.sReuter.net/
http://www.Auskennbert.de/
Nov 18 '08 #3
Rider wrote:
Hi All,
Here is the reason why i ak asking for ur help.

I have a edit form in which the values already stored in DB are
populated.
User can edit some or all the values in the form.
then he submit the form.

NOW I WANT SOME JAVASCRIPT / PHP FUNCTIONALITY WHICH WILL GIVE ME THE
types & values OF ALL ELEMENTS ON FORM WHICH SHOULD BE before
submitting & after submitting.
I HAVE TO COMPARE these values so that i can send only changed values
to server.

I HAD TRIED form.elements in JAVASCRIPT BUT IT GIVES SAME VALUES.

Regards,
Rider
Calm down. You don't have to yell to get help here.

If your data is stored in the db, then you should fetch the data from
the db again, and compare each item with its respective item in the form.

This should be done on the server end, not the client, which means all
data in the form goes to the server. Anything else would be unreliable.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 18 '08 #4
Erwin Moller wrote:
Rider schreef:
>Hi All,
Here is the reason why i ak asking for ur help.

Hi,
>>
I have a edit form in which the values already stored in DB are
populated.
User can edit some or all the values in the form.
then he submit the form.

NOW I WANT SOME JAVASCRIPT / PHP FUNCTIONALITY WHICH WILL GIVE ME THE
types & values OF ALL ELEMENTS ON FORM WHICH SHOULD BE before
submitting & after submitting.

Which should be WHAT?

>I HAVE TO COMPARE these values so that i can send only changed values
to server.

If you want to do that before submitting, you need a JavaScript solution.
And why don't you take the whole form, and update all posted? Why do you
want to 'flag' the elements that are changed?
I have to agree wholeheartedly here. In fact, I was going to post the
same comment. Only putting up the flagged stuff leads to complex
coding. Just stick the whole thing in with one update. MUUUUCCCCHHHHH
easier -- AND less error prone.
Nov 18 '08 #5
>I have a edit form in which the values already stored in DB are
>populated.
User can edit some or all the values in the form.
then he submit the form.

NOW I WANT SOME JAVASCRIPT / PHP FUNCTIONALITY WHICH WILL GIVE ME THE
types & values OF ALL ELEMENTS ON FORM WHICH SHOULD BE before
submitting & after submitting.
It is not uncommon to use hidden fields to contain the original values
of something so those values can be checked when the form is submitted.
This requires some manual effort. Yes, the original values can be
tampered with by the user, but since this user is authorized to edit
records anyway, there isn't much point.
>I HAVE TO COMPARE these values so that i can send only changed values
to server.

I HAD TRIED form.elements in JAVASCRIPT BUT IT GIVES SAME VALUES.

Regards,
Rider

Calm down. You don't have to yell to get help here.

If your data is stored in the db, then you should fetch the data from
the db again, and compare each item with its respective item in the form.
It is not uncommon to use the original values to check for multiple
editing of the same record by different people, especially in an
environment where people go to lunch or on extended vacations while
leaving the edit page open. This is used as a less-annoying
substitute for locking, which is impractical in a web-based environment
anyway.

You compare the original values on the page with the data from the
database. If they don't match, someone else has been editing the
page. You can tell what changes were made by this edit (original
form data vs. new form data) and what changes were made by the other
edit (original form data vs. database data). If you decide the
changes were conflicting, you can reject the change and ask the
user to do it again, showing them fresh original data. This also
works against the same user submitting the same change form twice.

Two separate changes to the 'salary' field are probably conflicting.
(One HR person was given instructions for a 5% raise for the
department; the other a 1% bonus for this employee. Two simultaneous
edits probably wipe out one or the other raise). A change to the
cell phone number and a change to the 'salary' field probably aren't.
>This should be done on the server end, not the client, which means all
data in the form goes to the server. Anything else would be unreliable.
Nov 18 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: iwasinnihon | last post by:
I don't usually like to do this, but I need help. I have gone over this code and cannot figure out why it doesn't work. First of all it doesn't check to see if you have filled in the required...
1
by: Randell D. | last post by:
HELP! I am determined to stick with this... I'm getting there... for those who haven't read my earlier posts, I'm createing what should be a simple function that I can call to check that...
4
by: James Bond 007 | last post by:
I am a novice to Javascript (can do simple text-based pop-ups, but not familiar with variable manipulation). I would like to have a Javascript that gives me the start time (I don't care about...
6
by: fidodido | last post by:
I was asked to do this.... Dynamically move "text1" and "hidden1" into the "form1" ..... Not by creating new elements, but moving the "text1" and "hidden1" elements into the form using javascript,...
3
by: awebguynow | last post by:
in other words, Can I make client side mod's before I submit a form and Post ? I guess its just a matter of cycling through the form elements and setting value to null (or empty string) for...
7
by: eric.goforth | last post by:
Hello, I'm working with a classic asp page that calls another classic asp page. The html in my calling page looks like: <form method="post"...
1
by: fugaki | last post by:
Hi everyone I'm learning asp, and i downloaded this script to teach me how to post form data from a webpage to an access database. I put it on the server so i could make sure that it worked, and...
13
by: Andrew Falanga | last post by:
HI, Just a warning, I'm a javascript neophyte. I'm writing a function to validate the contents of a form on a web page I'm developing. Since I'm a neophyte, this function is quite simple at...
5
by: programmerboy | last post by:
I never had this kind of issue before and it is completely surprising. I have a usercontrol where I need 2 forms to make 1 form. When I have only 1 form it submits the page to itself. I have spent...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.