Let me make sure I understand your question. You have a form which assigns a value to a Javascript variable ... you havn't submitted the form ... and you want that value? Correct?
Pounding at a thick stone wall won't move it, sometimes, you need to step back to see the way around.
rita mistry
Greenhorn
Joined: Dec 04, 2001
Posts: 27
posted
0
Hi Angela, Yes that is correct. Let me explain a bit more... I have a form which has a drop down for a list of companies. Each company has a certain number of projects assigned to it. So what I am trying to do is when the user selects a company, on the projects drop down below a list of all the projects belonging to this particular company will be displayed. I am using a Javabean to get the items from the database, but I need to pass the information of which company it is in the method parameter. I don't know how to do this so I thought I could store it in a Javascript var and then pass the value to a jsp var which then means I can use it for the javabean. I hope this makes sense. If you think there is a better way of doing this then I'm all ears. Kind Regards, Rita.
Hi Junilu, Correct me if I am wrong but doesn't the code that you have written above, just store the value in a javascript variable. I have already obtained the value I need from the form, but I need to now store it in a jsp variable. How do I do this? If the code above does this then I do apologise. I'll have a closer look at it. Kind regards, Rita.
Angela Poynton
Ranch Hand
Joined: Mar 02, 2000
Posts: 3143
posted
0
Look at the link he gave too!! It would seem it's not possible to do this without submitting the form!
rita mistry
Greenhorn
Joined: Dec 04, 2001
Posts: 27
posted
0
Thanks for all your help Angela and Junilu. If I find a way around the problem without having to submit I'll send a post. Thanks again Kind regards Rita.
Ugh! What you want can be done, and I did something very similar to it just last week, only your requirements are a bit more complicated. I assume that your list companies is pretty static while the list of projects can grow or shrink from time to time, right? You'll have to do some funky JavaScript/JSP to get this done the way you want it. I'll post some code in a bit... (need to modify some things to protect the innocent )
rita mistry
Greenhorn
Joined: Dec 04, 2001
Posts: 27
posted
0
Hi Junilu, The items in the company and project lists are outputted from the database. So both the company and project list will grow and shrink but in the case of the company list it won't be that often. I really appreciate your help. This coding is driving me nuts. Thanks very much. Rita.
I have a similar problem to the one discussed here. I am using a JSP bean in a javascript fn. This is no problem, but I need to pass a value from my HTML form to the Bean's method call. I have the value in the javascript but can't for the life of me figure out how to make the javascript variable available to the JAVA call. The j.s. function follows ('client' is the bean name) function x(){ //get value from textbox var t_val = document.forms[0].rec_text.value; if(t_val=="") return; <% client.recommendReceiver(t_val); %> document.forms[0].rec_text.value = ""; } The call works fine if I hard-code a value where <t_val> is...The prblem is t_val is a js variable and not recognized by JAVA.....I have lloked everywhere and found nothing - PLAESE HELP! -Elijah