Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assigning value to java string through javascript

Status
Not open for further replies.

phillyfino

Programmer
Joined
Jan 16, 2003
Messages
6
Location
US
Hi Everyone,

I've been trying to figure out how to assign a value that I grab through javascript into a java string. I need to grab the value of a drop down menu through javascript and assign that to a java string variable. Here's the code that I have right now:

<script>
var test = document.workingForm.letterName.options[document.workingForm.letterName.selectedIndex].value;
</script>

After getting the value of the drop down I try to assign it to a java string (I'm doing all this in a jsp page)

<%
String form_id = test;
String formName;
if (form_id!=null)
{
formName = FormList.getFormFileName(form_id);
}
%>

That doesn't work....any help would be appreciated :)
 
I don't believe you can do this, your problem being the fact that JSP is executed server side and your javascript being client side. The JSP is always executed (to produce the client output) before your javascript. What you could do instead is create a JSP page to handle a form submit with that option which if it is supposed to produce dynamic form options then it could redirect back to the form with a variable indictating the action to be taken.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top