Jscript working in chrome not in Firefox,IE

mohityadavx

Youngling
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

Master KOD3R
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().
 
OP
mohityadavx

mohityadavx

Youngling
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

Wahahaha~!
Staff member
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.
 
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

The Mighty Unkel!!!
Staff member
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"
 
Last edited:
Top Bottom