| Author |
Pass java value to javascript?
|
rahulJ james
Ranch Hand
Joined: Oct 03, 2008
Posts: 123
|
|
I have to access a java value in js from a jsp.. <% strReferralValue = tempValue + strReferralValue; %> How do I access the strReferralValue for a validation
|
 |
Amit Ghorpade
Bartender
Joined: Jun 06, 2007
Posts: 2551
|
|
How do I access the strReferralValue for a validation
Is strReferralValue coming from the same page or from the database? Since you want to do only the validation stuff, there should be no problem in both the above cases. If the variable is on the same page, then validation is straight forward, if its from a database, then you've already validated it before putting it there,isn't it. Please tell some details about what you are trying to do.
|
SCJP, SCWCD.
|Asking Good Questions|
|
 |
rahulJ james
Ranch Hand
Joined: Oct 03, 2008
Posts: 123
|
|
I am defining the variable in the JSP <%tempValue = agency.getFltReferralPerecentage(); (This value comes from a different class) strReferralValue = tempValue + strReferralValue; %> I wanted to use the value of strReferralValue in JS to do a validation to check whether the sum of all its values are not more than 100.. I am using struts 2 framework
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56185
|
|
You can;t really pass anything from the JSP to the JavaScript as they run on different machine at different times. But remember that with JSP, you can use Java values to create the template text that becomes the markup (HTML and JavaScript). For example: (assumes use of EL not scriptlets)
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
|
|
subject: Pass java value to javascript?
|
|
|