This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Help" Watch "Help" New topic
Author

Help

Amol Chavan
Greenhorn

Joined: Sep 04, 2005
Posts: 28
Dear Ranchers,

I'm trying to access a javascript variable value in JSP form.
I have a combo box which has some value.
On selecting one of its value I run a query with that parameter via setting up that parameter using preparedstatemnet.
But i don know how to access this value in JSP bcos its a javascript var.
here is code:
----------
(?,?):
one of question mark is loginid which i can access but another parameter is the one that I'm getting thru combo box --i.e.document.frmboids.otherboids.options[document.frmboids.otherboids.selectedIndex].value
---------------------------------------
if (ie)

msg7+='<select name="otherboids" size="1" onchange="return pgdropdnchk1(document.frmboids.otherboids.options[document.frmboids.otherboids.selectedIndex].value,document.frmboids)" style="font-size: 11px; font-family: Arial; color: Black;">';
var boid = document.frmboids.otherboids.options[document.frmboids.otherboids.selectedIndex];
alert("BOID: " +document.frmboids.otherboids.options[document.frmboids.otherboids.selectedIndex].value);

<%
sqlquery = "select * from the (select cast(vw.bo_init(?,?) as cdsl_admin.initial_tbl ) from dual)";

PreparedStatement preparedstatement1 = conn.prepareStatement(sqlquery);

preparedstatement1.setString(1, userinfo.getLoginid());

preparedstatement1.setString(2, boid.value);

rs = preparedstatement1.executeQuery();

while (rs.next()) {

--------------------------------

plz help me..
Thanks,
Amol


Thanks n Regards,<br />Amol
Kj Reddy
Ranch Hand

Joined: Sep 20, 2003
Posts: 1704
Duplicate of
http://www.coderanch.com/t/289330/JSP/java/Help

Amol, you can not access JavaScript variable in Java code for a JSP. To get the value of combo box you need to submit the form and retrieve the value from request object.
 
Consider Paul's rocket mass heater.
 
subject: Help