Click here to Skip to main content
15,867,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i change the value of java variable using javascript?

for example in java i was declare a variable like public static int x=0;

so now i want to change its value to 1 on onclick event of any div using javascript.
Posted

hi,

There is no direct way as java script on click event is executed on client browser while java code is written and execute on server side.

still if you want update server client click event you can use ajax
 
Share this answer
 
I suspect you are talking about a Java applet embedded in a web page. IF that should be the case you'll find how to do that here: Invoking Applet Methods From JavaScript Code[^]. The title is a bit misleading as the tutorial also shows these things:


  1. Invoke methods on Java objects
  2. Get and set fields in Java objects
  3. Get and set Java array elements
  4. Create new instances of Java objects


This link is also worth a read: Next-Generation Java Plug-In Technology Introduced in Java SE 6 update 10[^]

Cheers,

Manfred
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900