• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

javascript function not working when jsp load the first time but when refresh it works

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a jsp page that contain a javascript function to generate random alpha numeric characters. But the issue is when my page load the first time it does not work, however when i refresh the page it works fine. It is the same behaviour on all browsers.


Any suggestion why it is not working when my jsp page load for the first time?

Thanks a lot in advance.
 
Marshal
Posts: 67275
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps, just perhaps, it might help to show us the code?
 
ashley Jug
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

my apologies for not showing the code earlier. Please see below javascript function:


This is how i am calling the function from my jsp page:

<body onload="codeSec1();">

Thanks a lot for the quick response.


 
Sheriff
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And now, let's find out in what way does it "not work". (Apart from not being able to produce an upper-case Y, that is.)
 
Bear Bibeault
Marshal
Posts: 67275
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This way of addressing elements:is antiquated and highly fragile. It may not be the cause of your issues (unlikely in any case), but it's a problem waiting to happen.

Assign an id to the element, and use document.getElementById() to fetch a reference to the element.



 
ashley Jug
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Thanks for the suggestion, i have inserted an id as suggested in the last post and i have also include Y in the characters, just wanted to know if i have done it the right way:






Thanks again.
 
Bear Bibeault
Marshal
Posts: 67275
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it working? Has that helped?
 
ashley Jug
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have not test it on all browsers but Internet Explorer 8 its working fine .

Thanks a lot for the help and suggestions.

Will let you know as soon as I test it on all browsers.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!