• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Body onload method

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this code is not working:

body on[L]oad="if([%=request.getParameter("rateCode")%] .equals('0'))
clearFields();
else
empty();"
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic