DIGIT-ARC read-only archive · snapshot: July 23, 2026

Jscript working in chrome not in Firefox,IE

8 posts · originally from https://geek.digit.in/community/threads/jscript-working-in-chrome-not-in-firefox-ie.155446/

mohityadavx
mohityadavx Original post #1
Apr 11, 2012 at 11:50 PM
Hey!

I am having a strange problem here

*www.kagzaat.com/form_promissorynote.html

Now in this page if you select prepayment penalty as "Penalty" a textbox appears in chrome however this isn't happening in firefox, IE.

How could I resolve it. Plz Help!
nbaztec
nbaztec #2
Apr 12, 2012 at 8:51 PM
It's happening since it's throwing an error as 'penam not defined'. Most probably cause you document.getElementById('penam') too soon before the element is loaded.
Solutions:
* Put the script after the form
* Use document.onload/body.onload to assign values to vars
* Load vars in the function ppp() itself.

P.S. while we're at it you forgot to define 'l', being used in the function ppp().
mohityadavx
Apr 13, 2012 at 10:33 AM
It's happening since it's throwing an error as 'penam not defined'. Most probably cause you document.getElementById('penam') too soon before the element is loaded.
Solutions:
* Put the script after the form
* Use document.onload/body.onload to assign values to vars
* Load vars in the function ppp() itself.

P.S. while we're at it you forgot to define 'l', being used in the function ppp().

Thanks a lot lemme check that out
Faun
Faun #4
Apr 13, 2012 at 1:35 PM
Hey if you need inline validations for the field then you can use spry or jquery framework. Works awesomely good.

Let me know if you need help with that or nbaztec can help too.
abhidev
abhidev #5
Apr 13, 2012 at 2:20 PM
use jquery validation plugin
H
hsr #6
Apr 25, 2012 at 12:10 PM
I'd do what nbaztec said, but try this first, loose the var from var penam =

ie,

Code:
var penam = document.getElementById("penamh");
//cange ^ to this:
penam = document.getElementById("penamh");

and see if it works :)

p.s. your variable l is not defined either, just initialize it like
l = '';
RCuber
RCuber #7
Apr 25, 2012 at 4:23 PM
Code:
function ppp()
{
    var Prepay = document.input_details.prepayment.selectedIndex;
var pp2 = document.getElementById('penamh');
    if(Prepay == 2)
                   {

                       pp2.style.visibility = 'visible';
                       pp2.style.display='block';
                       l=l+1; // dono why this is used. 
               }
               else
                   {
                       pp2.style.visibility = 'hidden';
                       pp2.style.display= 'none';

                   }
}

try this.. use a different variable other than "prepayment" ..

also try debugging the code and checking where it is breaking. the code was breaking cause the script could not find "penam"
mohityadavx
Apr 26, 2012 at 1:31 PM
Thanks a lot to all of you I am gonna check all the suggestion and report back! :)