473,320 Members | 2,202 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,320 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 10278
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.