javascript with Firefox & IE
Posted: Mon Mar 30, 2009 8:26 am
Hi all, i've a problem with javascript.
The code is:
IE does it correctly but Mozilla makes me problems ('cause when I the press the button, that calls do_add_filter function, nothing happen).
I did some test and i found that the problem is in the string:
With IE parent_field contains "[object]".
and in Firefox it contains "null".
How can I solve it?
The code is:
Code: Select all
function do_add_filter(table){
var arr_labels = new Array();
var arr_values = new Array();
// ------
// changhe this with che correct objects
objForm = document.form1;
tot = parseInt(document.form1.hid_count.value, 10);
// ------
for(i=0; i<tot; i++){
if ( objForm.elements["chk_" + i].checked == true ){
arr_labels[arr_labels.length] = objForm.elements["hid_" + i].value;
arr_values[arr_values.length] = objForm.elements["chk_" + i].value;
}
}
if (window.opener == undefined) return false;
if (window.opener.document == undefined) return false;
var parentdoc = window.opener.document;
var parent_field = parentdoc.getElementById("hid_"+table);
if (parent_field == undefined) return false;
parent_field.value = arr_values.join(',');
var parent_labels = parentdoc.getElementById("label_"+table);
if (parent_labels == undefined) return false;
parent_labels.innerHTML = arr_labels.join('; ') + " ";
var parent_style = parent_labels.style;
parent_style.whiteSpace = "normal";
window.close();
}I did some test and i found that the problem is in the string:
Code: Select all
var parent_field = parentdoc.getElementById("hid_"+table);and in Firefox it contains "null".
How can I solve it?