Entry
how will you assign javascript variable to java variable?
Oct 28th, 2007 05:19
Sridhar Paidi, shanmugakumar arumugasamy,
Javascript is client side processing. So java program in an applicaton
server can't read the variables. Java script startes working once the
HTML code is generated by the servlet and is send to the browser.
However if you know what values you will need in a servlet, you can
pass the vaues to the servlet as a hidden value. Just use Javascript
and put the value in a hidden textbox and submit the page.
<script type="text/javascript">
function beforeSubmit()
{
var d = new Date() // Say you want to use variable d in the javacode
document.forms[0].hiddentextbox.value= d
document.forms[0].submit()
}
</script>