It's not a secret anymore!*
The moose likes HTML, CSS and JavaScript and the fly likes setting hidden field value using javascipt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "setting hidden field value using javascipt" Watch "setting hidden field value using javascipt" New topic
Author

setting hidden field value using javascipt

Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 387

These are steps I need to take in order to maintain a connection between a parent window and its child window:

1. User comes in to parent window where the hidden field value is set to "" and makes some changes to the form.
2. User clicks on a button to bring up a popup window but I need to save the changes he made to the parent window first.
3. I use javascript to update the parent window and then the parent window is reloaded with the user's changes.

HERE IS MY PROBLEM:
4. I then have to change the hidden field value on the reloaded form.
5. Check the value of the hidden field value.
6. Run the function that then opens a popup window from that reloaded form and therefore keeping all the values I need to pass on to the popup window.

How do I accomplish step #4? I have been trying to get around this issue in varrious ways but to no avail. Any help or direction would be greatly appreciated.

Thanks.

[ June 12, 2007: Message edited by: Melinda Savoy ]
[ June 13, 2007: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

Are you using a server-side tmplating system such as JSP? That's the best place to pre-populate the values.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 387

Bear -- thanks for the reply.

If I understand your question correctly, I am using JSP, however, I was pre-populating the hidden field value because I wanted to check that that value was indeed populating and then run my function to load the child window (popup window) but I was checking the value when initially coming into the form and consequently my function would execute when i did not want it to until the user clicked a button on the parent form to save the changes made by the user.

This is why I do not need the value populated until AFTER the page reloaded.

I hope that is making sense.
[ June 12, 2007: Message edited by: Melinda Savoy ]
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 387

Let me try to get around my issue another way, is there a way to know when a page has been reloaded so that I can then execute a window.open to popup another window and still keep the values in the parent page in tact so that the child window does not loose its connection to the parent page?

I'm open. I've been trying to use a hidden field value but that get reset each time the page is reloaded. I was trying to set the hidden field value the next time I came to the parent page but that was reset, again, each time the parent page was reloaded.

Again, what I'm basically trying to do is save the changes made to the parent page before doing a window.open function to launch a popup window that I need to be able to communicate back the parent page with.

Surely there must be a way that I'm just not knowledgeable about and would appreciate ANY alternate ideas.

Thanks!!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
A better solution is to et away from pop up windows and look into either using an iframe which can be placed on top of the page or look into using the XMLHttpRequest object (Ajax).

Eric
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 387

Eric,

Thanks for the reply. With the help of a colleague, because we're using the Stripes framework, I was able to change the value of the hidden value via javascript and because Stripes maintains state we were able to capture the value and then run the next javascript function that launched the popup window.

Thanks for all the replies and direction given. You guys are the best.

Regards.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting hidden field value using javascipt