| Author |
javascript function not working when jsp load the first time but when refresh it works
|
ashley Jug
Ranch Hand
Joined: Sep 02, 2011
Posts: 60
|
|
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.
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50693
|
|
|
Perhaps, just perhaps, it might help to show us the code?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
ashley Jug
Ranch Hand
Joined: Sep 02, 2011
Posts: 60
|
|
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.
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 13842
|
|
|
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
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50693
|
|
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
Joined: Sep 02, 2011
Posts: 60
|
|
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
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50693
|
|
|
Is it working? Has that helped?
|
 |
ashley Jug
Ranch Hand
Joined: Sep 02, 2011
Posts: 60
|
|
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.
|
 |
 |
|
|
subject: javascript function not working when jsp load the first time but when refresh it works
|
|
|