Forum Moderators: open

Message Too Old, No Replies

How to change the POST data of a form using javascript ?

Changing POST data using javascript

         

solanki_21

10:55 am on May 9, 2008 (gmt 0)

10+ Year Member



Hello All,

I'm facing some problem in javascript.

Scenario:

I've 2 pages lets say page1.htm and page2.htm.

On Page1.htm we have a submit buttons "Search"

Click on "Search" gives the list of employees.
with every employee there is another button "Display" of type submit.

When the user click on the "Display" button, all the details of the employee gets displayed below the list and another button "EDIT" gets visible.

The button "EDIT" is used to edit the details of that employee
(This is not of type Submit).

Onclick of "EDIT" another page2.htm is opened in another window.
Which displays the employee info in change mode.

After finishing the changes the user want the parent window to be refreshed automatically.

Problem :

I've used window.parent.location.reload(true); to refresh the
parent window (Page1.htm).

Now since to display the details of the employee, the user clicked on "Display" button (which is of type submit) which got stored as
POST data.

Now the below details gets refreshed but the list does not, because the page resends the POST data again back to the server.

I hope you have understood my problem, also i can not do the modification in Page1.htm

Waiting for an early reply.

Thanks
Sandeep Solanki
IBM India.

Otaku

2:53 pm on May 12, 2008 (gmt 0)

10+ Year Member



If the form on Page2 updates the data, then I don't understand why the list isn't refreshed.

If the data went to the server from the Page2, and stored in a database, and Page1 is refreshed, then all data on Page1 are taken from the database, and they should be new.

Please explain in more detail what exactly doesn't refresh and why.

solanki_21

6:16 am on May 13, 2008 (gmt 0)

10+ Year Member



hi Otaku,
Thanks for the reply.
The list view in Page1.htm doesn't refresh, coz the event sent to the server is "Display" not "Search" coz the last event fired was "Display".

Anyhow i've resolve the problem now. The solution is to update the list of employees in the handler of "Display" event, previously it was only written in "Search" handler.

But i would love to know if i can change the POST data of 1 page from another page using javascript.

Otaku

10:45 am on May 13, 2008 (gmt 0)

10+ Year Member



Not sure about that. Looks like if you have a reference to a page, you can locate and change everything on it.

var form = window.parent.document.forms["BadForm"];
form.elements["somename"].value = "new value";
form.submit();

Didn't test that but I hope you get the idea :)

solanki_21

10:58 am on May 13, 2008 (gmt 0)

10+ Year Member



Got your point..
I did try that...
But...
Like you have 2 submit buttons.. S1, S2.
and you clicked S1.
when you will execute
**********************
var form = window.parent.document.forms["BadForm"];
form.elements["somename"].value = "new value";
form.submit();
***********************

The event sent to the server will be S1 not S2.
I hope u got my point...

Otaku

11:44 am on May 13, 2008 (gmt 0)

10+ Year Member



No, I don't O_o

The server gets all form field names and their values:

name=Jack&surname=Sheperd&sex=male&engaged=1&...

No matter how many Submit buttons a form has, the server gets the same set of names and values.

What are the events you're talking about?