<%
HttpSession session1 = request.getSession();
String Marks = session1.getAttribute("Marks").toString();
String Percentage= session1.getAttribute("Percentage").toString();
String marks1 =session1.getAttribute("marks1").toString();
int total = 25;
int m1 = Integer.parseInt(Marks);
int m2 = Integer.parseInt(marks1);
float m3 = ((m1+m2)*100)/25;
%>
I want to store the float m3 value in a JavaScript variable.
JavaScript / jQuery code:
<script>
$(document).ready(function() { // 6,32 5,38 2,34
$("#test-circle").circliful({
animation: 1,
animationStep: 5,
foregroundBorderWidth: 12,
backgroundBorderWidth: 12,
percent: 92,
textSize: 25,
textStyle: 'font-size: 10px;',
textColor: '#666',
multiPercentage: 2,
percentages: [10, 20, 30]
})
});
</script>
I want that my JavaScript variable percent should get the value of my Java variable m3. I want this because I want to get the value in percent variable dynamic not static as I have written 92 in front of percent.
I know that on the same page you can't store
a JavaScript variable into a Java variable because the JSP page is loaded first.
But in my case I want to store the Java variable m3 which is in float into my JavaScript variable percent.
I have a very little knowledge of jQuery so please help!
92with<%= m3 %>. However, please note that result of((m1+m2)*100)/25is an integer value, not afloatvalue. If you want floating point, you should define variable asdoubleand divide by25dto force adoubleresult.code markdown. So it's important to indent code, but also to NOT indent text.