By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,640 Members | 2,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,640 IT Pros & Developers. It's quick & easy.

Javascript code not running in FIREFOX

P: n/a
Hi I have the following code in java script, it is not giving proper
output in FIREFOX but running fine in IE... can anybody help me out to
make this run in FIREFOX .
<script language="JavaScript">
var cntlName;
var eleTarget = document.getElementById('hiding');

function showOrHide(){
alert ("hi");
var eleSource = event.srcElement;

if (event.srcElement) {
//for IE
var eleSource = event.srcElement;
}
else {
//for Firefox
var eleSource = event.target;
}

if (eleSource.value == 'MGRPAY') {
//for IE
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}

for(var i=0; i<preProcessControlArray.length; i++){
cntlName = eval(preProcessControlArray[i]);
if (cntlName.m_oSubmit.name.toLowerCase() == 'p_par_rad_role'){
if (cntlName.m_oForm.length) {
for( var j=0; j<cntlName.m_oForm.length; j++ ){
if (j == 0) {
cntlName.m_oForm[j].focus();
cntlName.m_oForm[j].click();
if (cntlName.m_oForm[j].value == 'MGRPAY') {
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}
//For IE
if(cntlName.m_oForm[j].attachEvent)
cntlName.m_oForm[j].attachEvent('onpropertychange',
showOrHide);
//for firefox
else
cntlName.m_oForm[j].addEventListener('onchange',
showOrHide,false);
}
}
else {
cntlName.m_oForm.focus();
cntlName.m_oForm.click();
if (cntlName.m_oForm.value == 'MGRPAY') {
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}
}
}
</script>

Jun 6 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
i don't know what error u r encountering
did u install FireBug to debug ur js in FF?

i think u will have better feedback with that tool
Coder wrote:
Hi I have the following code in java script, it is not giving proper
output in FIREFOX but running fine in IE... can anybody help me out to
make this run in FIREFOX .
<script language="JavaScript">
var cntlName;
var eleTarget = document.getElementById('hiding');

function showOrHide(){
alert ("hi");
var eleSource = event.srcElement;

if (event.srcElement) {
//for IE
var eleSource = event.srcElement;
}
else {
//for Firefox
var eleSource = event.target;
}

if (eleSource.value == 'MGRPAY') {
//for IE
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}

for(var i=0; i<preProcessControlArray.length; i++){
cntlName = eval(preProcessControlArray[i]);
if (cntlName.m_oSubmit.name.toLowerCase() == 'p_par_rad_role'){
if (cntlName.m_oForm.length) {
for( var j=0; j<cntlName.m_oForm.length; j++ ){
if (j == 0) {
cntlName.m_oForm[j].focus();
cntlName.m_oForm[j].click();
if (cntlName.m_oForm[j].value == 'MGRPAY') {
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}
//For IE
if(cntlName.m_oForm[j].attachEvent)
cntlName.m_oForm[j].attachEvent('onpropertychange',
showOrHide);
//for firefox
else
cntlName.m_oForm[j].addEventListener('onchange',
showOrHide,false);
}
}
else {
cntlName.m_oForm.focus();
cntlName.m_oForm.click();
if (cntlName.m_oForm.value == 'MGRPAY') {
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}
}
}
</script>


Jun 6 '06 #2

P: n/a

I am using this java script code to show and hide a prompt box in
Cognos reportnet , it is working fine in IE , but when it comes to
Firefox then it does not becomes activated . Even if I click any button
in same prompt , the next prompt does not show up.

It is not returning any error to me but its simply not working.So if
the code can be modified so that it works fine with Firefox.

so*********@gmail.com wrote:
i don't know what error u r encountering
did u install FireBug to debug ur js in FF?

i think u will have better feedback with that tool
Coder wrote:
Hi I have the following code in java script, it is not giving proper
output in FIREFOX but running fine in IE... can anybody help me out to
make this run in FIREFOX .
<script language="JavaScript">
var cntlName;
var eleTarget = document.getElementById('hiding');

function showOrHide(){
alert ("hi");
var eleSource = event.srcElement;

if (event.srcElement) {
//for IE
var eleSource = event.srcElement;
}
else {
//for Firefox
var eleSource = event.target;
}

if (eleSource.value == 'MGRPAY') {
//for IE
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}

for(var i=0; i<preProcessControlArray.length; i++){
cntlName = eval(preProcessControlArray[i]);
if (cntlName.m_oSubmit.name.toLowerCase() == 'p_par_rad_role'){
if (cntlName.m_oForm.length) {
for( var j=0; j<cntlName.m_oForm.length; j++ ){
if (j == 0) {
cntlName.m_oForm[j].focus();
cntlName.m_oForm[j].click();
if (cntlName.m_oForm[j].value == 'MGRPAY') {
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}
//For IE
if(cntlName.m_oForm[j].attachEvent)
cntlName.m_oForm[j].attachEvent('onpropertychange',
showOrHide);
//for firefox
else
cntlName.m_oForm[j].addEventListener('onchange',
showOrHide,false);
}
}
else {
cntlName.m_oForm.focus();
cntlName.m_oForm.click();
if (cntlName.m_oForm.value == 'MGRPAY') {
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}
}
}
</script>


Jun 6 '06 #3

P: n/a
Coder wrote:
Hi I have the following code in java script, it is not giving
proper output in FIREFOX but running fine in IE... can anybody
help me out to make this run in FIREFOX .

<script language="JavaScript">
var cntlName;
var eleTarget = document.getElementById('hiding');

function showOrHide(){
alert ("hi");
var eleSource = event.srcElement; ^^^^^
Firefox/Mozilla/Gecko browsers do not use an global - event - property,
instead passing event objects as the argument to the event handling
function. Because the - event - Identifier does not refer to a defined
property of the global object it evaluates as the undefined value, and
the subsequent attempt to read the - srcElement - property of an
undefined value will have firefox error-out.Firefox/Mozilla/Gecko
browsers do not use an global - event - property, instead passing event
objects as the argument to the event handling function. Because the -
event - Identifier does not refer to a defined property of the global
object it evaluates as the undefined value, and the subsequent attempt
to read the - srcElement - property of an undefined value will have
firefox error-out.
if (event.srcElement) {
//for IE
var eleSource = event.srcElement;
}
else {
//for Firefox
var eleSource = event.target;
}

if (eleSource.value == 'MGRPAY') {
//for IE
eleTarget.style.display = 'block';
If - eleSource - is an input element, as the use of its value property
may imply, then its default CSS display style is 'inline' not 'block'.
}
else {
eleTarget.style.display = 'none';
}
}
function showOrHide(ev){
var eleSource;
ev = ev || window.event;
if(eleSource = (ev.srcElement||ev.target)){
if(eleSource.value == 'MGRPAY'){
eleTarget.style.display = '';
}else{
eleTarget.style.display = 'none';
}
}
}
for(var i=0; i<preProcessControlArray.length; i++){
cntlName = eval(preProcessControlArray[i]);
The contents of - preProcessControlArray - are not shown here so what
this code does, or may be intended to do, is unknown. Though generally
any use of - eval - is indicative of failing to do something else what
would be objectively better.

However, if this array contains control names in the form of string
then - eval -ing them will be equivalent to resolving Identifiers as
properties on the scope chain, or more likely the global object. IE
makes (at least some) named elements into properties of the global
object that refer to the elements. Firefox/Mozilla/Gecko browsers do not
tend to do this.
if (cntlName.m_oSubmit.name.toLowerCase() == 'p_par_rad_role'){
if (cntlName.m_oForm.length) {
for( var j=0; j<cntlName.m_oForm.length; j++ ){
if (j == 0) {
cntlName.m_oForm[j].focus();
cntlName.m_oForm[j].click();
if (cntlName.m_oForm[j].value == 'MGRPAY') {
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}
//For IE
if(cntlName.m_oForm[j].attachEvent)
cntlName.m_oForm[j].attachEvent('onpropertychange',
showOrHide);
//for firefox
else
cntlName.m_oForm[j].addEventListener('onchange',

<snip> ^^^^^^^^
The addEventListener method takes the event name as its argument not the
name of the intrinsic event property, so here it would be 'change'
rather than 'onchange'.

The onchange hander is not triggered under equivalent conditions to the
onpropertychange even in IE, and IE does support onchange.

Richard.
Jun 6 '06 #4

P: n/a
I have changed that part to 'change' but it is still not working there
is some issue with the showOrHide part which I am unable to figure out
....because in Firefox the alert ("hi 2"); is not coming up and that is
the code for showOrHide

<script language="JavaScript">
var cntlName;
var eleTarget = document.getElementById('hiding');

function showOrHide(){

var eleSource = event.srcElement;
if (event.srcElement) {
//for IE
alert ("hi 1");
var eleSource = event.srcElement;
}
else {
//for Firefox
alert ("hi 2");
var eleSource = event.target;
}

if (eleSource.value == 'MGRPAY') {
//for IE
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}

for(var i=0; i<preProcessControlArray.length; i++){
cntlName = eval(preProcessControlArray[i]);
if (cntlName.m_oSubmit.name.toLowerCase() == 'p_par_rad_role'){
if (cntlName.m_oForm.length) {
for( var j=0; j<cntlName.m_oForm.length; j++ ){
if (j == 0) {
cntlName.m_oForm[j].focus();
cntlName.m_oForm[j].click();
if (cntlName.m_oForm[j].value == 'MGRPAY') {
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}
//For IE
if(cntlName.m_oForm[j].attachEvent)
cntlName.m_oForm[j].attachEvent('onpropertychange',
showOrHide);
//for firefox
cntlName.m_oForm[j].addEventListener('change',showOrHide,false);
}
}
else {
cntlName.m_oForm.focus();
cntlName.m_oForm.click();
if (cntlName.m_oForm.value == 'MGRPAY') {
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}
}
}
</script>

Richard Cornford wrote:
Coder wrote:
Hi I have the following code in java script, it is not giving
proper output in FIREFOX but running fine in IE... can anybody
help me out to make this run in FIREFOX .

<script language="JavaScript">
var cntlName;
var eleTarget = document.getElementById('hiding');

function showOrHide(){
alert ("hi");
var eleSource = event.srcElement;

^^^^^
Firefox/Mozilla/Gecko browsers do not use an global - event - property,
instead passing event objects as the argument to the event handling
function. Because the - event - Identifier does not refer to a defined
property of the global object it evaluates as the undefined value, and
the subsequent attempt to read the - srcElement - property of an
undefined value will have firefox error-out.Firefox/Mozilla/Gecko
browsers do not use an global - event - property, instead passing event
objects as the argument to the event handling function. Because the -
event - Identifier does not refer to a defined property of the global
object it evaluates as the undefined value, and the subsequent attempt
to read the - srcElement - property of an undefined value will have
firefox error-out.
if (event.srcElement) {
//for IE
var eleSource = event.srcElement;
}
else {
//for Firefox
var eleSource = event.target;
}

if (eleSource.value == 'MGRPAY') {
//for IE
eleTarget.style.display = 'block';


If - eleSource - is an input element, as the use of its value property
may imply, then its default CSS display style is 'inline' not 'block'.
}
else {
eleTarget.style.display = 'none';
}
}


function showOrHide(ev){
var eleSource;
ev = ev || window.event;
if(eleSource = (ev.srcElement||ev.target)){
if(eleSource.value == 'MGRPAY'){
eleTarget.style.display = '';
}else{
eleTarget.style.display = 'none';
}
}
}
for(var i=0; i<preProcessControlArray.length; i++){
cntlName = eval(preProcessControlArray[i]);


The contents of - preProcessControlArray - are not shown here so what
this code does, or may be intended to do, is unknown. Though generally
any use of - eval - is indicative of failing to do something else what
would be objectively better.

However, if this array contains control names in the form of string
then - eval -ing them will be equivalent to resolving Identifiers as
properties on the scope chain, or more likely the global object. IE
makes (at least some) named elements into properties of the global
object that refer to the elements. Firefox/Mozilla/Gecko browsers do not
tend to do this.
if (cntlName.m_oSubmit.name.toLowerCase() == 'p_par_rad_role'){
if (cntlName.m_oForm.length) {
for( var j=0; j<cntlName.m_oForm.length; j++ ){
if (j == 0) {
cntlName.m_oForm[j].focus();
cntlName.m_oForm[j].click();
if (cntlName.m_oForm[j].value == 'MGRPAY') {
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}
//For IE
if(cntlName.m_oForm[j].attachEvent)
cntlName.m_oForm[j].attachEvent('onpropertychange',
showOrHide);
//for firefox
else
cntlName.m_oForm[j].addEventListener('onchange',

<snip> ^^^^^^^^
The addEventListener method takes the event name as its argument not the
name of the intrinsic event property, so here it would be 'change'
rather than 'onchange'.

The onchange hander is not triggered under equivalent conditions to the
onpropertychange even in IE, and IE does support onchange.

Richard.


Jun 6 '06 #5

P: n/a
I have changed that part to 'change' but it is still not working there
is some issue with the showOrHide part which I am unable to figure out
....because in Firefox the alert ("hi 2"); is not coming up and that is
the code for showOrHide

<script language="JavaScript">
var cntlName;
var eleTarget = document.getElementById('hiding');

function showOrHide(){

var eleSource = event.srcElement;
if (event.srcElement) {
//for IE
alert ("hi 1");
var eleSource = event.srcElement;
}
else {
//for Firefox
alert ("hi 2");
var eleSource = event.target;
}

if (eleSource.value == 'MGRPAY') {
//for IE
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}

for(var i=0; i<preProcessControlArray.length; i++){
cntlName = eval(preProcessControlArray[i]);
if (cntlName.m_oSubmit.name.toLowerCase() == 'p_par_rad_role'){
if (cntlName.m_oForm.length) {
for( var j=0; j<cntlName.m_oForm.length; j++ ){
if (j == 0) {
cntlName.m_oForm[j].focus();
cntlName.m_oForm[j].click();
if (cntlName.m_oForm[j].value == 'MGRPAY') {
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}
//For IE
if(cntlName.m_oForm[j].attachEvent)
cntlName.m_oForm[j].attachEvent('onpropertychange',
showOrHide);
//for firefox
cntlName.m_oForm[j].addEventListener('change',showOrHide,false);
}
}
else {
cntlName.m_oForm.focus();
cntlName.m_oForm.click();
if (cntlName.m_oForm.value == 'MGRPAY') {
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}
}
}
</script>

Richard Cornford wrote:
Coder wrote:
Hi I have the following code in java script, it is not giving
proper output in FIREFOX but running fine in IE... can anybody
help me out to make this run in FIREFOX .

<script language="JavaScript">
var cntlName;
var eleTarget = document.getElementById('hiding');

function showOrHide(){
alert ("hi");
var eleSource = event.srcElement;

^^^^^
Firefox/Mozilla/Gecko browsers do not use an global - event - property,
instead passing event objects as the argument to the event handling
function. Because the - event - Identifier does not refer to a defined
property of the global object it evaluates as the undefined value, and
the subsequent attempt to read the - srcElement - property of an
undefined value will have firefox error-out.Firefox/Mozilla/Gecko
browsers do not use an global - event - property, instead passing event
objects as the argument to the event handling function. Because the -
event - Identifier does not refer to a defined property of the global
object it evaluates as the undefined value, and the subsequent attempt
to read the - srcElement - property of an undefined value will have
firefox error-out.
if (event.srcElement) {
//for IE
var eleSource = event.srcElement;
}
else {
//for Firefox
var eleSource = event.target;
}

if (eleSource.value == 'MGRPAY') {
//for IE
eleTarget.style.display = 'block';


If - eleSource - is an input element, as the use of its value property
may imply, then its default CSS display style is 'inline' not 'block'.
}
else {
eleTarget.style.display = 'none';
}
}


function showOrHide(ev){
var eleSource;
ev = ev || window.event;
if(eleSource = (ev.srcElement||ev.target)){
if(eleSource.value == 'MGRPAY'){
eleTarget.style.display = '';
}else{
eleTarget.style.display = 'none';
}
}
}
for(var i=0; i<preProcessControlArray.length; i++){
cntlName = eval(preProcessControlArray[i]);


The contents of - preProcessControlArray - are not shown here so what
this code does, or may be intended to do, is unknown. Though generally
any use of - eval - is indicative of failing to do something else what
would be objectively better.

However, if this array contains control names in the form of string
then - eval -ing them will be equivalent to resolving Identifiers as
properties on the scope chain, or more likely the global object. IE
makes (at least some) named elements into properties of the global
object that refer to the elements. Firefox/Mozilla/Gecko browsers do not
tend to do this.
if (cntlName.m_oSubmit.name.toLowerCase() == 'p_par_rad_role'){
if (cntlName.m_oForm.length) {
for( var j=0; j<cntlName.m_oForm.length; j++ ){
if (j == 0) {
cntlName.m_oForm[j].focus();
cntlName.m_oForm[j].click();
if (cntlName.m_oForm[j].value == 'MGRPAY') {
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}
//For IE
if(cntlName.m_oForm[j].attachEvent)
cntlName.m_oForm[j].attachEvent('onpropertychange',
showOrHide);
//for firefox
else
cntlName.m_oForm[j].addEventListener('onchange',

<snip> ^^^^^^^^
The addEventListener method takes the event name as its argument not the
name of the intrinsic event property, so here it would be 'change'
rather than 'onchange'.

The onchange hander is not triggered under equivalent conditions to the
onpropertychange even in IE, and IE does support onchange.

Richard.


Jun 6 '06 #6

P: n/a
I have changed that part to 'change' but it is still not working there
is some issue with the showOrHide part which I am unable to figure out
....because in Firefox the alert ("hi 2"); is not coming up and that is
the code for showOrHide

<script language="JavaScript">
var cntlName;
var eleTarget = document.getElementById('hiding');

function showOrHide(){

var eleSource = event.srcElement;
if (event.srcElement) {
//for IE
alert ("hi 1");
var eleSource = event.srcElement;
}
else {
//for Firefox
alert ("hi 2");
var eleSource = event.target;
}

if (eleSource.value == 'MGRPAY') {
//for IE
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}

for(var i=0; i<preProcessControlArray.length; i++){
cntlName = eval(preProcessControlArray[i]);
if (cntlName.m_oSubmit.name.toLowerCase() == 'p_par_rad_role'){
if (cntlName.m_oForm.length) {
for( var j=0; j<cntlName.m_oForm.length; j++ ){
if (j == 0) {
cntlName.m_oForm[j].focus();
cntlName.m_oForm[j].click();
if (cntlName.m_oForm[j].value == 'MGRPAY') {
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}
//For IE
if(cntlName.m_oForm[j].attachEvent)
cntlName.m_oForm[j].attachEvent('onpropertychange',
showOrHide);
//for firefox
cntlName.m_oForm[j].addEventListener('change',showOrHide,false);
}
}
else {
cntlName.m_oForm.focus();
cntlName.m_oForm.click();
if (cntlName.m_oForm.value == 'MGRPAY') {
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}
}
}
</script>

Richard Cornford wrote:
Coder wrote:
Hi I have the following code in java script, it is not giving
proper output in FIREFOX but running fine in IE... can anybody
help me out to make this run in FIREFOX .

<script language="JavaScript">
var cntlName;
var eleTarget = document.getElementById('hiding');

function showOrHide(){
alert ("hi");
var eleSource = event.srcElement;

^^^^^
Firefox/Mozilla/Gecko browsers do not use an global - event - property,
instead passing event objects as the argument to the event handling
function. Because the - event - Identifier does not refer to a defined
property of the global object it evaluates as the undefined value, and
the subsequent attempt to read the - srcElement - property of an
undefined value will have firefox error-out.Firefox/Mozilla/Gecko
browsers do not use an global - event - property, instead passing event
objects as the argument to the event handling function. Because the -
event - Identifier does not refer to a defined property of the global
object it evaluates as the undefined value, and the subsequent attempt
to read the - srcElement - property of an undefined value will have
firefox error-out.
if (event.srcElement) {
//for IE
var eleSource = event.srcElement;
}
else {
//for Firefox
var eleSource = event.target;
}

if (eleSource.value == 'MGRPAY') {
//for IE
eleTarget.style.display = 'block';


If - eleSource - is an input element, as the use of its value property
may imply, then its default CSS display style is 'inline' not 'block'.
}
else {
eleTarget.style.display = 'none';
}
}


function showOrHide(ev){
var eleSource;
ev = ev || window.event;
if(eleSource = (ev.srcElement||ev.target)){
if(eleSource.value == 'MGRPAY'){
eleTarget.style.display = '';
}else{
eleTarget.style.display = 'none';
}
}
}
for(var i=0; i<preProcessControlArray.length; i++){
cntlName = eval(preProcessControlArray[i]);


The contents of - preProcessControlArray - are not shown here so what
this code does, or may be intended to do, is unknown. Though generally
any use of - eval - is indicative of failing to do something else what
would be objectively better.

However, if this array contains control names in the form of string
then - eval -ing them will be equivalent to resolving Identifiers as
properties on the scope chain, or more likely the global object. IE
makes (at least some) named elements into properties of the global
object that refer to the elements. Firefox/Mozilla/Gecko browsers do not
tend to do this.
if (cntlName.m_oSubmit.name.toLowerCase() == 'p_par_rad_role'){
if (cntlName.m_oForm.length) {
for( var j=0; j<cntlName.m_oForm.length; j++ ){
if (j == 0) {
cntlName.m_oForm[j].focus();
cntlName.m_oForm[j].click();
if (cntlName.m_oForm[j].value == 'MGRPAY') {
eleTarget.style.display = 'block';
}
else {
eleTarget.style.display = 'none';
}
}
//For IE
if(cntlName.m_oForm[j].attachEvent)
cntlName.m_oForm[j].attachEvent('onpropertychange',
showOrHide);
//for firefox
else
cntlName.m_oForm[j].addEventListener('onchange',

<snip> ^^^^^^^^
The addEventListener method takes the event name as its argument not the
name of the intrinsic event property, so here it would be 'change'
rather than 'onchange'.

The onchange hander is not triggered under equivalent conditions to the
onpropertychange even in IE, and IE does support onchange.

Richard.


Jun 6 '06 #7

P: n/a
Coder wrote:
I have changed that part to 'change' but it is still not working there
is some issue with the showOrHide part which I am unable to figure out
....because in Firefox the alert ("hi 2"); is not coming up and that is
the code for showOrHide

Well, part of the problem is that you are still trying to use a global
"event" property which, as was mentioned, Firefox does not have.
Jun 7 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.