# Jscript working in chrome not in Firefox,IE



## mohityadavx (Apr 11, 2012)

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 (Apr 12, 2012)

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)

nbaztec said:


> 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
> ...



Thanks a lot lemme check that out


----------



## Faun (Apr 13, 2012)

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 (Apr 13, 2012)

use jquery validation plugin


----------



## hsr (Apr 25, 2012)

I'd do what nbaztec said, but try this first, loose the var from var penam = 

ie, 


```
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 (Apr 25, 2012)

```
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)

Thanks a lot to all of you I am gonna check all the suggestion and report back!


----------

