...

View Full Version : Internet Explorer doesn't execute my script!



wider
06-25-2009, 10:20 PM
Hello everybody!
I wrote a script which have to replace a text with a form but, as it's is used to be, it works just on safari and firefox: i have just learned javascript no i'm not a master in compatibility tecniques... Please help me fixing the script:


var c = 0; //Just a counting variable
function change(element, mode) {
var node = window.document.getElementById(element);
if(c == 0) { inner = node; }
c++;

var day = 31; //Will create a form
var month = 12;
var year = 2015;
days = null; months = null; years = null;

var i = 1;
for(i = 1; i<= day; i++) //Giorni
days = days + '<option value="' + i + '">' + i + '</option> ';
for(i = 1; i<= month; i++) //Mese
months = months + '<option value="' + i + '">' + i + '</option> ';
for(i = 2009; i<= year; i++) //anni
years = years + '<option value="' + i + '">' + i + '</option>';

//Write the form
var former = '<div class="selecter"><table><tr><td><select name="day[]">' + days + '</select></td><td>';
former = former + '<select name="month[]">' + months + '</select></td><td>';
former = former + '<select name="year">' + years + '</select></td><td><img src="theme/images/icons/back.png" onclick="change(\'' + element + '\', 2);" border="0" alt="" class="edit" /><img src="theme/images/icons/edit.png" onclick="document.edit.submit();" border="0" alt="" class="edit" /></td></tr></table></div>';

parent = node.parentNode;
newform = document.createElement("form");
newform.style.display = 'inline';
newform.action = 'system/compile.php';
newform.name = 'edit';
newform.method = 'post';
newform.id = element;
parent.replaceChild(newform, node);
novoel = newform.appendChild(node);

if(mode == 1)
newform.innerHTML = former;
else
{ // Rewrite the original code if required
parent = novoel.parentNode;
ripristino = document.createElement("h4");
ripristino.style.display = 'inline';
ripristino.id = element;
parent.replaceChild(ripristino, novoel);
ripristino.appendChild(novoel);
ripristino.innerHTML = inner.innerHTML;
ripristino.id = inner.id;
ripristino.onclick = inner.onclick;
}
}

ckeyrouz
07-02-2009, 06:56 PM
days = null; months = null; years = null;


Try to initialize these variables to empty strings instead of null. When they are null you cannot concatenate anything to them.

days = ""; months = ""; years = "";



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum