Getting values from scriptlet to Java script.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   angela_Chint
Posted On:   Tuesday, October 23, 2007 05:42 PM

I have some values in the scriptlet of the JSP. How can I get it to the Javascript to do some validation, while submitting the form. Eg: <% // Code for passing the html field values in the same page to the java. FileUploadForm bean = (FileUploadForm)pageContext.findAttribute("FileUploadForm"); if (bean.getTheFile() != null) { bean.setTheFileSize(bean.getTheFile().getFileSize()); } System.out.println("bean.getTheFileSize() = " + bean.getTheFileSize()); %> This fileSize I want to get to Javascript validation function. I appreciate any help. Thanks    More>>

I have some values in the scriptlet of the JSP. How can I get it to the Javascript to do some validation, while submitting the form.


Eg:

<%
// Code for passing the html field values in the same page to the java.

FileUploadForm bean = (FileUploadForm)pageContext.findAttribute("FileUploadForm");


if (bean.getTheFile() != null) {
bean.setTheFileSize(bean.getTheFile().getFileSize());
}

System.out.println("bean.getTheFileSize() = " + bean.getTheFileSize());
%>

This fileSize I want to get to Javascript validation
function.


I appreciate any help.


Thanks

   <<Less

Re: Getting values from scriptlet to Java script.

Posted By:   Stephen_McConnell  
Posted On:   Sunday, October 28, 2007 10:10 AM

It's not pretty, but create an >input< html element with a specific "id", "name" and "value". The value will be the variable or value in a scriptlet you want to access.


Then use the "document.getElementById("idname"); to access the value of the input element...


Make sure it's in the Form block.


Stephen McConnell

About | Sitemap | Contact