Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Script in JSP  RSS feed

 
Prabha Dhandapani
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I ma actually trying to call a fuction that has been defined in a java script from a jsp but it is giving me lot of errors...
Here is the code:
if ( cobrandingLogo == null ) {
{
<script language="Javascript">loadImage(false, companyLogo)</script>
}

the script is :
var companyLogo;
function loadImage(useLogo, companyLogo) {
var number = 10;
var increment = Math.floor(Math.random() * number);

if (useLogo == true) {
document.imagePlaceholder.src = "pageServices/images/CompanyLogos/" + companyLogo + ".gif";
}
else {
document.imagePlaceholder.src = "/images/random/" + increment + ".jpg";
document.imagePlaceholder.height = "100";
}
}
would appreciate if some one can help me with the corrected code. This is very urgent so any help ASAP would be appreciated.
Thanks,
Prabha
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaScript is part of the HTML not the Java code so do it like this:
if ( cobrandingLogo == null ) {
{ %>
<script language="Javascript">loadImage(false, companyLogo)</script>
<% }
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!