hi friends....i am stuck in my code
i am trying to assign a value of javascript variable to a java variable but it is giving errors
is there any way of doing this.....i searched a lot but found none
any suggestion will be highly appreciated
Printable View
hi friends....i am stuck in my code
i am trying to assign a value of javascript variable to a java variable but it is giving errors
is there any way of doing this.....i searched a lot but found none
any suggestion will be highly appreciated
In what are you trying to do this?
So you have some javascript in an html page?
Is the Java in an applet or on the web server?
So your Ajax call to the server will have to have a parameter in it containing the value held in the variable. Then on the server you can extract that in the usual way from the request (or whatever framework you happen to be using).
Are you saying that you want the js variable to be sent to the server and then reset the js variable to something returned by the server?
i want to pass the value of js variable in a bean.....how is that possible??
Do you understand how your browser communicates with the web server?
You can't simply send a bean...especially since (as far as your browser is concerned) a bean is meaningless.
u put some code here to see exactly what u want
now the error is coming on line "var a=<%=nameObj.check(date)%>"Code:var date=frm.date1.value;
var a=<%=nameObj.check(date)%>
that date cannot be resolved
You can't do that.
Java runs on the server.
That javascript runs on the client after all the Java code has finished running.
You can do..Iam storing some boolean in jsp and trying to assign the boolean to javascript.After assigning based on boolean type iam doing if..see below
test.jsp
----------
<%
boolean inputFlag = true;
%>
<script language ="javascript">
var flag = <%= inputFlag%>;
if(flag )
document.writeln("Hi");
else
document.writeln("Bye");
</script>
</HEAD>
</HTML>
this is not what i asked
well this is true but the reverse is not i.e you cannot assign the value of a js variable to a java variable and moreover my problem was that i was trying to pass the value of a js variable in a bean which was giving errors.....
u can do one thing...u can have some textfield or hidden field.assign the value to this and retreive thru jsp.
yes u can do as u said and simplfy in receiving the value without going to other page
in this case i have to go to other page