• Post Reply Bookmark Topic Watch Topic
  • New Topic

Body onload method  RSS feed

 
Debashree Halder
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
at the time of loading the body I need to check one condition based on that I need to call one particular method.
Can I use following?

Regards,
 
Chad Cook
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to execute any javascript on page load use onload="" in the body tag. For what you're talking about you might want to set up your page so that you are printing the values from your request to the page and let the javascript do the logic. Also, it's sometimes cleaner to have onload call a method and move the code to the method for readability as it's hard to read a lot of javascript squeezed together on one line.


or

[ August 19, 2005: Message edited by: Chad Cook ]
 
Debashree Halder
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this code is not working:

body on[L]oad="if([%=request.getParameter("rateCode")%] .equals('0'))
clearFields();
else
empty();"
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Eric pointed out in an earlier post, you have a basic misunderstanding of what JSP is all about. JSP code executes on the serveer in order to compose an HTML page to send to the client. Once sent, no Java code remains in the page.

Since this is not an HTML question, I've moved this to the JSP forum.
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should do a View Source on the page you get to see what the generated javascript looks like. My guess is you want something like this:



But if you plan to work with web applications, you MUST understand the difference between Java and Javascript.

-Yuriy
[ August 19, 2005: Message edited by: Yuriy Zilbergleyt ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!