RIRedinPA Posted November 7, 2008 Share Posted November 7, 2008 I have a site that has a table and within some of the cells of the table are checkboxes. Checking one launches a script which displays a form for the user to input some data. I'm using onChange to launch the script. It works fine in Safari and FF but not in IE. In IE, if you check a box in one row, nothing happens, but if you check a second box then the script fires. (It shows a hidden div which holds the form - closing the div (another javascript) then brings up the second form. If that wasn't clear, click checkbox 1, nothing, click checkbox 2, the form for checkbox 1 appears, close form for checkbox 1 then the form for checkbox 2 appears... I can't even really debug this in IE because it doesn't have something on the level of Firebug in 7 and 8 is not on my desktop. I was reading on the internets and someone had posted that IE 7 doesn't respond to onChange, to make that onClick but when I did I got the same results. I can't post the code as it is being made on the fly using AJAX and PHP and it's huge...here's the PHP that writes the cell with a checkbox in it: if (strlen($copydrop) == 0 ) { $etablecontent .= "<td id=\"copydrop_$y\" onMouseover=\"this.style.backgroundColor='#ffffff'\" onMouseout=\"this.style.backgroundColor='$backgroundcolor'\" style='background-color:$backgroundcolor;' class='td4'><input type=\"checkbox\" onmousedown=\"updateDB('copydrop_$y', 'commwin', '$thisid', 'editorial');\" onMouseover=\"this.style.backgroundColor='#ffffff'\" onMouseout=\"this.style.backgroundColor='$backgroundcolor'\" style='background-color:$backgroundcolor;'> </td>"; } else { $timestamp = gettimestamp('copydrop', $thisid); $etablecontent .= "<td id=\"copydrop_$y\" onMouseover=\"this.style.backgroundColor='#ffffff'\" onMouseout=\"this.style.backgroundColor='$backgroundcolor'\" style='background-color:$backgroundcolor;' class='td4'><input type=\"text\" size=\"20\" onmousedown='updateDB('copydrop_$y', this.value, '$thisid', 'editorial');' onMouseover=\"this.style.backgroundColor='#ffffff'\" onMouseout=\"this.style.backgroundColor='$backgroundcolor'\" value='$timestamp' style='font-size: 10px;' style='background-color:$backgroundcolor;'> <a href=\"javascript:void(0);\" onmousedown=\"showdata('$thisid', 'copydrop_$y');\"><img src=\"images/downarrow.png\" border=\"0\" id=\"copydrop_$y_img\"></a></td>"; } Here's the Javascript code that shows the form: function updateDB(cellid, dbvalue, thisid, view) { //check what type of form item, if checkbox, offer comment box, then update if (dbvalue == "commwin") { //show comment win //get dbfield var dbfield = getdbfield(cellid); //get middle of window var viewportsizes = getviewport(); var viewportsizes = viewportsizes.split("::"); var viewportwidth = parseFloat(viewportsizes[0]); var viewportheight = parseFloat(viewportsizes[1]); //set position var divleft = parseFloat(viewportwidth/2 - (400/2)) //move window document.getElementById("datadiv").style.left = divleft + "px"; document.getElementById("datadiv").style.top = "5px"; //get timestamp var currentTime = new Date() var month = currentTime.getMonth() + 1 var day = currentTime.getDate() var year = currentTime.getFullYear() var hour = currentTime.getHours(); var minute = currentTime.getMinutes(); //fixes if (month < 10) { month = "0" + month; } if (day < 10) { day = "0" + day; } if (hour > 12) { hour = hour - 12; } if (hour > 10) { hour = "0" + hour; } if(minute < 10) { minute = "0" + minute; } var timestamp = month + " " + day + ", " + year + " | " + hour + ":" + minute; //write html var commform = "<form name='commform'><table cellpadding='0' cellspacing='0' border='0'><tr valign='top'><td>Time: " + timestamp + "</td></tr><tr valign='top'><td>Enter your comments below (you can leave this blank)<p><textarea name='commentbox' rows='5' cols='30'></textarea></td></tr><tr valign='top'><a href=\"javascript:void(0);\" onmousedown=\"updateDB('" + cellid + "', 'commvalue', '" + thisid + "', '" + view + "');\" style=\"background-color: #CC6600; color: #fff; width: 100px; height: 30px; text-align: center; padding: 3px;\">Submit</a></td></tr></table></form><p><a href=\"javascript:void(0)\" onmousedown=\"closewin('datadiv');\">Close</a>"; document.getElementById('datadiv').innerHTML = commform; //show panal slidedown("datadiv") } else if (dbvalue == "commvalue") { dbvalue = document.commform.commentbox.value; slideup('datadiv'); //see if browser is ajax compatible var xmlHttp = checkajax(); //get dbfield var dbfield = getdbfield(cellid); xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { var returneddata = xmlHttp.responseText; dataarray = returneddata.split("***"); document.getElementById("welcomeframe").style.display = "none"; document.getElementById('msgbox').style.display = 'block'; document.getElementById("msgbox").innerHTML = dataarray[0]; document.getElementById('tabledisplays').style.display = 'block'; document.getElementById('tabledisplays').innerHTML = dataarray[1] + "<br>" + dataarray[2]; document.getElementById('viewbuttons').style.display = 'block'; document.getElementById("toolbox").innerHTML = dataarray[3]; document.getElementById("toolbox").style.display = "block"; } } xmlHttp.open("GET","updatedb.php?thisid=" + thisid + "&dbfield=" + dbfield + "&dbvalue=" + dbvalue + "&view=" + view, true); xmlHttp.send(null); } else { //see if browser is ajax compatible var xmlHttp = checkajax(); //get dbfield var dbfield = getdbfield(cellid); xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { var returneddata = xmlHttp.responseText; dataarray = returneddata.split("***"); document.getElementById("welcomeframe").style.display = "none"; document.getElementById('msgbox').style.display = 'block'; document.getElementById("msgbox").innerHTML = dataarray[0]; document.getElementById('tabledisplays').style.display = 'block'; document.getElementById('tabledisplays').innerHTML = dataarray[1] + "<br>" + dataarray[2]; document.getElementById('viewbuttons').style.display = 'block'; document.getElementById("toolbox").innerHTML = dataarray[3]; document.getElementById("toolbox").style.display = "block"; } } xmlHttp.open("GET","updatedb.php?thisid=" + thisid + "&dbfield=" + dbfield + "&dbvalue=" + dbvalue + "&view=" + view, true); xmlHttp.send(null); }//end type check } Like I said though, this works fine in Safari and FF. I put an alert after the function call and even that didn't come up so my guess is this is an issue with IE even being able to get to the function. Any help would be appreciated. Quote Link to comment Share on other sites More sharing options...
RIRedinPA Posted November 7, 2008 Author Share Posted November 7, 2008 Changed onChange to onClick and it worked fine. Stupid IE. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.