wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Repopulating form problem 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 "Repopulating form problem " Watch "Repopulating form problem " New topic
Author

Repopulating form problem

Mariusz Bogucki
Greenhorn

Joined: Mar 09, 2004
Posts: 13
Hi

I have a little problem. I have a simple form that takes me to some sth.do, it looks sth. like this:
textfield name
textfield name
dropdown list of items
go button

I use struts
now after I push the go button, form is populated, I am redirected to the action servlet, values are evaluted, if any errors I return to this page, no problems everything is fine.
Ammong the items I also have new item if new item is selected as an opction I am taken on my way through the new Item webpage and again I come back to the primary site, no problem with repopulating the form since I keep the bean with its values.
But the problem arises when I try to use dropdown list to navigate. WHen I change the focus on my dropdown list I want the page to be reloaded according to the value that is selected on the dropdown list. I use javascript for that. So I basicly redirect to some action servlet that is always used before redirectting to this page. Now my problem is that when i use redirect from the javascript no action form is created or at least I dont know how to do that and I lose the content of name fields. I could pass them as a parameters but it sounds kind of messy. so how can I navigate from the javascript function responding to onchange atribute so my actionForm were populated with the valuse taht are already typed.


this is my javascript,I would like to know if there is any way to use action of the form that the list belongs to, from the javascript after changing focus on the dropdown list


<script type="text/javascript">
<!--
function schoolChange(form){
selInd = document.majorForm.school.selectedIndex;
ID = document.majorForm.school.options[selInd].value;

top.location.href ="major.do?id="+ID;
}

//-->
</script>



I hope you understood ...

Thank you

[ April 29, 2005: Message edited by: Mariusz Bogucki ]
[ April 29, 2005: Message edited by: Mariusz Bogucki ]

SCJP,SCWCD
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Moved to the HTML/Javascript forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Rather than submitting the request via



submit the form under Javascript control with

Mariusz Bogucki
Greenhorn

Joined: Mar 09, 2004
Posts: 13
Thank You very much.
heh, very simple, I has been long time since I used JS, I guess its time to review...
 
 
subject: Repopulating form problem
 
Similar Threads
repopulating
Repopulating fields?
Struts Issue - Repopulating a Form Bean
repopulating form
Repopulating form in struts2