JavaScript - Display Property Error Only In Ie7
I have a page:
http://www.girlscoutsmoheartland.org...progsearch.php that works perfectly fine in every browser I try, except for actual IE7 (it even works fine in IE8 emulating IE7). When you search for something on that page and have a display of results, each result has a link that changes a table row's display to visible, and hides the row when clicked again. It doesn't do that in IE7. There are no errors or warning in Firefox's Error Console. But IE7 has an "Error on Page" notice (which does NOT appear in IE8 emulating IE7), that says: Line: 59 Char: 11 Error: Could not get the display property. Invalid argument. The script in question is this, with what would be line 59 indicated: Code: <script type="text/javascript"> <!-- function toggle_visibility(id) { var e = document.getElementById(id); var f = document.getElementById(id + "b"); if(e.style.display == 'table-row') e.style.display = 'none'; else e.style.display = 'table-row'; <<-- This is line 59 if(f.style.display == 'table-row') f.style.display = 'none'; else f.style.display = 'table-row'; } //--> </script> I really don't know what to do, or where to begin. Everything in my limited knowledge seems to be working just fine. Most of my site's visitors use IE8, but enough use actual IE7 that I really need to fix this. Thanks for any help or advice! Liam Similar TutorialsJavascript: Code: function hoverMenu(listItem, menuName) { if (document.getElementById(menuName).isActive == "1") { var listItemHeight = document.getElementById(listItem).offsetHeight; var itemTop = document.getElementById(listItem).offsetTop; var itemLeft = document.getElementById(listItem).offsetLeft; document.getElementById(menuName).style.top = itemTop + listItemHeight + "px"; document.getElementById(menuName).style.left = itemLeft + "px"; document.getElementById(menuName).style.display = "block"; document.getElementById(menuName).style.opacity = "1.0"; document.getElementById(menuName).isActive = "0"; } else { var listItemHeight = document.getElementById(listItem).offsetHeight; var itemTop = document.getElementById(listItem).offsetTop; var itemLeft = document.getElementById(listItem).offsetLeft; document.getElementById(menuName).style.top = itemTop + listItemHeight + "px"; document.getElementById(menuName).style.left = itemLeft + "px"; document.getElementById(menuName).style.display = "block"; menuFade(menuName); document.getElementById(menuName).isActive = "0"; } } function hoverMenuTier2(listItem, menuName) { if (document.getElementById(menuName).isActive == "1") { var itemTop = document.getElementById(listItem).offsetTop; var itemLeft = document.getElementById(listItem).offsetLeft; document.getElementById(menuName).style.top = itemTop + "px"; document.getElementById(menuName).style.left = itemLeft + "px"; document.getElementById(menuName).style.display = "block"; document.getElementById(menuName).style.opacity = "1.0"; document.getElementById(menuName).isActive = "0"; } else { var itemTop = document.getElementById(listItem).offsetTop; var itemLeft = document.getElementById(listItem).offsetLeft; document.getElementById(menuName).style.top = itemTop + "px"; document.getElementById(menuName).style.left = itemLeft + "px"; document.getElementById(menuName).style.display = "block"; menuFade(menuName); document.getElementById(menuName).isActive = "0"; } } function hideThis(menuName) { document.getElementById(menuName).style.display = "none"; document.getElementById(menuName).style.opacity = "0"; } function showMenu(menuName) { document.getElementById(menuName).style.display = "block"; document.getElementById(menuName).style.opacity = "1.0"; document.getElementById(menuName).isActive = "1"; } HTML: Code: <div id='db-sub' class='ddm-db' onmouseover="showMenu('db-sub');" onmouseout="hideThis('db-sub');"> <ul> <a href='#'><li id='dba' class='sub'>1</li></a> <a href='#'><li class='sub'>2</li></a> <a href='#'><li class='sub'>3</li></a> <a href='#'><li class='sub'>4</li></a> <a href='#'><li class='sub'>5</li></a> <a href='#'><li class='sub'>6</li></a> <a href='#'><li class='sub'>7</li></a> <a href='#'><li class='sub'>8</li></a> <a href='#'><li id='dbq' onmouseover="hoverMenuTier2('dbq', 'dbq-sub');" onmouseout="hideThis('dbq-sub');" class='submenuArrow'>9</li></a> <a href='#'><li class='sub'>10</li></a> <a href='#'><li class='sub'>11</li></a> <a href='#'><li class='sub'>12</li></a> <a href='#'><li class='sub'>13</li></a> </ul> </div> The remaining HTML for the the 'dqb-sub' element that is displayed follows an identical format to 'db-sub'. Mousing over the upper elements produces a drop-down menu that is aligned with the position of the top-most element in question. Mousing over the 'dbq' element produces the element 'dbq-sub' at the (0,0) position of the window, which is my issue. I believe it has to do with the fact that I'm setting the display property to 'none', which essentially destroys the element, along with its properties. What doesn't make sense is that while the 'db-sub' element is set to a block display type, it should have valid, non-zero offsets. I'd like the 'dbq-sub' element to position based on where the 'dbq' element is. Any ideas? I wrote a script that creates 2 absolutely positioned divs, in perfect alignment, one on top of the other. I want to use javascript to manipulate the display property of each div to show one div at a time by toggling each div's display property between none and block with an onClick event handler attached to the link. This script works fine when the javascript function has no parameters, because the div id's are inserted directly into the getElementById function. When I say it works, I mean the div with id=cal2 displays onload, then disappears when the Show Calendar link is clicked. The div that appears in its place has a link that does the reverse when clicked. I want to create multiple pairs of overlapping divs that toggle their visibility, so I want to put parameters inside the functions that identify the specific pair of divs that need to be toggled per function call. When I try to use variables/parameters in the functions to insert specific div id's into getElementById, it does not work. PLEASE NOTE, the code below has div id's in green that don't have quotes of any kind. It still works in my firefox browser. I thought id's needed quotes, but it works without. I don't know why. The code below works, but has no parameters in the functions: Code: <!DOCTYPE html> <xhtml> <head> <title>Practice Calendar</title> <style type="text/css"> .practicecalendar { position: absolute; top: 0px; left: 0px; margin: 0; width: 18em; background: #B3FF99; text-align: center; } .practiceschedule { position: absolute; top: 0px; left: 0px; margin: 0; width: 18em; background: #99E6FF; text-align: center; } </style> <script type="text/javascript"> <!-- function showSchedule(){ document.getElementById('sch2').style.display = 'block'; document.getElementById('cal2').style.display = 'none'; } function showCalendar(){ document.getElementById('cal2').style.display = 'block'; document.getElementById('sch2').style.display = 'none'; } //--> </script> </head> <body> <div id= cal2 class='practicecalendar' style=' display: block; '> <p>Calendar</p> <p><a href='' onClick='showSchedule(); return false'>Show Schedule</a></p> </div> <div id= sch2 class='practiceschedule' style=' display: none; '> <p>Schedule</p> <p><a href='' onClick='showCalendar(); return false'>Show Calendar</a></p> </div> </body> </xhtml> When I add the information in red to the same script above, I get the script below that does not work. Code: <!DOCTYPE html> <xhtml> <head> <title>Practice Calendar</title> <style type="text/css"> .practicecalendar { position: absolute; top: 0px; left: 0px; margin: 0; width: 18em; background: #B3FF99; text-align: center; } .practiceschedule { position: absolute; top: 0px; left: 0px; margin: 0; width: 18em; background: #99E6FF; text-align: center; } </style> <script type="text/javascript"> <!-- function showSchedule( sch,cal ){ document.getElementById( 'sch' ).style.display = 'block'; document.getElementById( 'cal' ).style.display = 'none'; } function showCalendar( cal,sch ){ document.getElementById( 'cal' ).style.display = 'block'; document.getElementById( 'sch' ).style.display = 'none'; } //--> </script> </head> <body> <div id= cal2 class='practicecalendar' style=' display: block; '> <p>Calendar</p> <p><a href='' onClick='showSchedule( 'sch2','cal2' ); return false'>Show Schedule</a></p> </div> <div id= sch2 class='practiceschedule' style=' display: none; '> <p>Schedule</p> <p><a href='' onClick='showCalendar( 'cal2','sch2' ); return false'>Show Calendar</a></p> </div> </body> </xhtml> When I remove the single quotes from the blue code , it does not work either. Code: <!DOCTYPE html> <xhtml> <head> <title>Practice Calendar</title> <style type="text/css"> .practicecalendar { position: absolute; top: 0px; left: 0px; margin: 0; width: 18em; background: #B3FF99; text-align: center; } .practiceschedule { position: absolute; top: 0px; left: 0px; margin: 0; width: 18em; background: #99E6FF; text-align: center; } </style> <script type="text/javascript"> <!-- function showSchedule(sch,cal){ document.getElementById('sch').style.display = 'block'; document.getElementById('cal').style.display = 'none'; } function showCalendar(cal,sch){ document.getElementById('cal').style.display = 'block'; document.getElementById('sch').style.display = 'none'; } //--> </script> </head> <body> <div id=cal2 class='practicecalendar' style=' display: block; '> <p>Calendar</p> <p><a href='' onClick='showSchedule( sch2,cal2 ); return false'>Show Schedule</a></p> </div> <div id=sch2 class='practiceschedule' style=' display: none; '> <p>Schedule</p> <p><a href='' onClick='showCalendar( cal2,sch2 ); return false'>Show Calendar</a></p> </div> </body> </xhtml> Thanks for reading all of this. Does anyone know what I'm missing? Hi! I have the following javascript and accompanying html but the i keep getting the error: Unable to get value of the property 'options': object is null or undefined pointing to this line of the code " $thisSelectedValue = $formField.options[ $formField.selectedIndex ].value;" Can someone help me please... thanks in advance. Javascript Code: <script type="text/javascript"> $allValues = new Array(); $allValues[0] = 'Choose One'; $allValues[1] = 'A1'; $allValues[2] = 'A2'; $allValues[3] = 'A3'; $allValues[4] = 'A4'; $allValues[5] = 'A5'; function stripDupelicateValues(inElementId) { // get current list of all selected values $selectedValues = new Array(); for( $position in $allValues ) { if( $position != 0 ) { $formField = eval( 'document.crewchange.emp_' + $position ); // preserve our selected values $thisSelectedValue = $formField.options[ $formField.selectedIndex ].value; $selectedValues[$thisSelectedValue] = true; } } for( $position in $allValues ) { if( $position != 0 ) { $formField = eval( 'document.crewchange.emp_' + $position ); // preserve our selected values $thisSelectedValue = $formField.options[ $formField.selectedIndex ].value; // wipe out the previous choices $formField.options.length = 0; // create default option $formField.options[0] = new Option( $allValues[0], 0 ); for( $optionValue in $allValues ) { // add each of our non selected values if( $selectedValues[$optionValue] != true ) { $formField.options[$formField.options.length] = new Option( $allValues[$optionValue], $optionValue ); } // create the option for our selected value else if( $thisSelectedValue == $optionValue ) { $index = $formField.options.length; if( $optionValue != 0 ) { $formField.options[$index] = new Option( $allValues[$optionValue], $optionValue ); $formField.options[$index].selected = true; } } } } } } </script> Html Code: <form action="cc2.php" method="post" name="cc"> <select name='emp[]' id='emp_1' onChange='stripDupelicateValues(this.id)'> <option>Choose One</option> <option value='1'>A1</option> <option value='2'>A2</option> <option value='3'>A3</option> <option value='4'>A4</option> <option value='5'>A5</option> </select> </form> Error Msg Code: Message: Unable to get value of the property 'options': object is null or undefined Hey, this error ONLY occurs in IE. "Unexpected call to method or property access." I pinpointed it to this line: o.appendChild(e); The full function is: Code: function aO(d, t, src, p, id ){ alert('aO has begun.'); var o, e, i; if (!ie){ o = cE('object');o.data = src; } else { o = cE('embed');o.src = src; } o.id = id; if (!ie){ p.push( ['movie', src] ); } if ( typeof(id) === 'String' ){o.id = id;} o.type = t; o.style.width = '210px'; for(i = 0; i < p.length; i++){ e = cE('param'); e.name = p[i][0]; e.value = p[i][1]; o.appendChild(e); } d.appendChild(o); alert('aO has finished.'); } What it does is write a flash object to the page. The FULL code is: Code: <!-- Chat Options --> <noscript> It appears that you do not have JavaScript enabled. Please enable it, otherwise you cannot view the chatbox. </noscript> <div id="chatWrap"> <ul id="ccon" style="display:none;"> <li><a href="javascript:void(0);" onclick="switchChat();">Switch to <span id="cnext">Chat Title</span></a></li> <li><a href="javascript:void(0);" onclick="resizeChat();"><span id="csize">Expand</span> Chat</a></li> <li><a href="javascript:void(0);" onclick="toggleChat();"><span id="chatToggle">Close</span> Chat</a></li> </ul> </div> <div id="cbox" style="display:block;"></div> <!-- Chat Script --> <script type="text/javascript"><!-- // --><![CDATA[ var chats = []; chats[0] = ['Main Chat', 'Uber-Anime-Chat', 1236404792847]; chats[1] = ['Roleplay Chat','Uber-Anime-Roleplay', 1236403501064]; var chat = { 'opt': 'a=000000&b=100&c=999999&d=848484&e=000000&g=CCCCCC&h=333333&i=29&j=CCCCCC&k=666666&l=333333&m=000000&n=CCCCCC&s=1&t=0', 'ref': 'www.uber-anime.com', 'cur': 0, 'delay': 1.5, 'params': [['wmode','transparent'] , ['allowscriptaccess','always'] , ['allownetworking','internal']] } var chatState = 0; var chatStates = []; chatStates[0] = ['Expand', '300px']; chatStates[1] = ['Shrink', '500px']; function cE(e){return document.createElement(e);} function cT(s){return document.createTextNode(s);} var ie = false; function aO(d, t, src, p, id ){ var o, e, i, embed; if (!ie){ o = cE('object');o.data = src; } else { o = cE('embed');o.src = src; } o.id = id; if (!ie){ p.push( ['movie', src] ); } if ( typeof(id) === 'String' ){o.id = id;} o.type = t; o.style.width = '210px'; for(i = 0; i < p.length; i++){ e = cE('param'); e.name = p[i][0]; e.value = p[i][1]; o.appendChild(e); if(ie) { embed = cE('embed'); embed.setAttribute(p[i][0], p[i][1]); } } if(ie) o.appendChild(embed); d.appendChild(o); } function switchChat() { if (document.getElementById('cbox').hasChildNodes()) while (document.getElementById('cbox').childNodes.length >= 1) document.getElementById('cbox').removeChild(document.getElementById('cbox').firstChild); var x = chat.cur; chat.cur = (x + 1) % chats.length; var c = chats[x]; var src = 'http://st.chatango.com/flash/group.swf?ref=' + chat.ref + '&gn=' + c[1] + '.chatango.com&cid=' + c[2] + '&' + chat.opt; document.getElementById('cbox').innerHTML = ''; aO( document.getElementById('cbox'), 'application/x-shockwave-flash', src, chat.params, 'chat' ); document.getElementById('ccon').style.display = 'block'; // qfix document.getElementById('cnext').innerHTML = chats[chat.cur][0]; document.getElementById('chat').style.height = chatStates[chatState][1]; document.getElementById('csize').innerHTML = chatStates[chatState][0]; } function resizeChat(){ if(chatState == 0) chatState = 1; else chatState = 0; document.getElementById('chat').style.height = chatStates[chatState][1]; document.getElementById('csize').innerHTML = chatStates[chatState][0]; } function toggleChat() { if(document.getElementById('cbox').style.display == 'block') { display = 'none'; chatStateTxt = 'Open'; } else { display = 'block'; chatStateTxt = 'Close'; } document.getElementById('chatToggle').innerHTML = chatStateTxt; document.getElementById('cbox').style.display = display; } function chatInit(){ if (navigator.userAgent.indexOf('MSIE') !== -1){ie = true;} if ( chat.delay <= 0 ){ switchChat(); } else { i = cE('img'); i.src = 'ajax-loader.gif'; document.getElementById('cbox').appendChild(i); document.getElementById('cbox').appendChild(cT(' Loading Chat... If this message stays up, your browser may not be supported.')); var clk = setTimeout( function(){ switchChat(); }, chat.delay * 1000 ); } delete chatInit; } chatInit(); //]]> </script> Can anyone tell me how to fix this? This is ridiculously irritating, and it's important that I can fix it ASAP. Hi, I'm a newbie to the forum and jquery and have been trying to use it for a slick form wizard i found here. http://thecodemine.org/ It's almost complete but IE keeps giving me an error I've tried everything to fix with no luck. I'm using jquery-1.4.2.min.js and the error it's giving me is Unexpected call to method or property access. line 103 character 460 The code it highlights is: Code: {this.nodeType===1&&this.appendChild(a)})}, at the end of this line. Complete line is: Code: wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})}, Any help would be greatly appreciated. Thanks! FYI: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) Timestamp: Tue, 15 Nov 2011 16:45:53 UTC Message: Unexpected call to method or property access. Line: 103 Char: 460 Code: 0 URI: http://custsatdev/contact/jqueryform...y-1.4.2.min.js Hi guys im trying to give users a warning message with javascript when the submit my login form without inserting any new data. But I can't seem to find out how to stop the form from going to the login.php here is my code. Code: <form name="te" onsubmit='login();' action='login.php' method='post'> <input name='username' maxlength='14' value='Username' type='text' /> <input name='password' maxlength='20' value='Password' type='password' /> <input type="submit" name="login" value="Login" /> </form> javascript: Code: <script type="text/javascript"> function login() { var username = document.te.username.value; var password = document.te.password.value; if (username == 'Username' || username == '') { alert('empty username!'); return false; } else { if (password == 'Password' || password == '') { alert('empty pass'); return false; } } return true; } </script> www.e-decals.com/dev displays fine in Firefox and Safari, (link color a { color : #b2b2b2 correct) but IE showing default link colors around images in multibox - IE error he User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB6; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30618) Timestamp: Thu, 5 Nov 2009 15:11:40 UTC Message: Object doesn't support this property or method Line: 467 Char: 4 Code: 0 URI: http://www.e-decals.com/dev/multibox/multibox.js Any ideas? It works in FF but i can seem to find what the issue is here is the code Code: <script type="text/javascript">//<![CDATA[ window.addEvent('domready',function(){ new viewer($$('#box1 img)'),{ mode: 'alpha', interval: 5000 }).play(true); }); //]]> </script> <script type="text/javascript"> <!-- // When DOM is ready $(document).ready(function(){ // ------- Submit First Form ------- $("#contact").submit(function(){ var str = $(this).serialize(); $.ajax({ type: "POST", url: "contact.php", data: str, success: function(msg){ $("#note").ajaxComplete(function(event, request, settings){ if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form { result = '<div class="notification_ok">Your message has been sent. Thank you!</div>'; $("#fields").hide(); } else { result = msg; } $(this).html(result); }); } }); return false; }); this is line 64 -> </script> The error is Syntax error code0 line:64 char:1 . Please if anyone can help. Any help would be awesome and much appreciated! I'm trying to change an id by referencing the previous site the user was on. In this case the user will be coming from either facebook or linkedin. I'm not sure if i'm calling the referrer property correctly. Again, any help is greatly appreciated! <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script language="JavaScript"> if(document.referrer.toLowerCase().indexOf("facebook") != -1) { document.getElementById("phone").innerHTML = "555.555.5555"; } else if (document.referrer.toLowerCase().indexOf("linkedin") != -1) { document.getElementById("phone").innerHTML = "222.222.2222"; } else { //Default code } </script> </head> <body> <p id="phone">123.456.7890</p> </body> Hi, This is my first post while learning Javascript and jQuery as total noob. I have something like this: Code: var desc = "This is your title and here is even more that might be added so that we can get at least 60 characters or so"; var desc = desc.trim().substring(0, 40).split(" ").slice(0, -1).join(" ") + "...more"; alert(shortText ); It is actually being used on a page that calls a description from a MySQL table, but this example fails in exactly the same manner. Although FF and other browsers successfully initiate the script with errors, but IE loops endlessly and freezes up. FireBug reports "reference to undefined property a[d]". Using jQuery 1.6.2. I'm not really sure what property is undefined here and how this can work without freezing IE. Thanks in advance for any help! AJ I have this simple manual photo slide show. It shows four photos and when you click the next button and it moves one photo over and one photo back for the previous button. I have to moving by changing the CSS property of 'left' by 195 pixels each move. So for it to move next it will subtract 195 pixels from the left property and for moving back it add 195 pixels to the left property. I have the code setup so when you click it changes the property of left to either -195 or 195 pixels but I need it so it actually does the math, not just give it a set value. But I don't know how to do that. Code: function MM_changeProp(objId,x,theProp,theValue) { //v9.0 var obj = null; with (document){ if (getElementById) obj = getElementById(objId); } if (obj){ if (theValue == true || theValue == false) eval("obj.style."+theProp+"="+theValue); else eval("obj.style."+theProp+"='"+theValue+"'"); } } function nextPhoto() { MM_changeProp('fanThumbWrapOne','','left','-195px','DIV') } function prevPhoto() { MM_changeProp('fanThumbWrapOne','','left','195px','DIV') } so where you see -195px and 195px in the functions for nextPhoto and prevPhoto I need those to actually be functions where it subtracts 195px or adds 195px. I'm using ccs3PIE with my site. What I want to do is check if a DOM element has a css property like border-radius and then add a class to it. The problem I'm having is that I don't know how to check for the css property. I've been searching for it for a couple of hours now and I can't find anything that seems to work. Any ideas? Hi I need to change the font color of the disabled textboxes of our application. These disabled textboxes exist at thousands of places both at pageload or disabled conditionally clientside. I am aware that in IE8 there is no other way to change the fontcolor except use readonly. So i thought that maybe if I changed the .disabled property to something like - Code: Object.disabled { function set() { this.readOnly = value; } function get() { return this.readOnly; } } then it would make my task much easier. I searched and found out that Object.defineProperty ,may do the trick. However i am getting the mull reference error. Is there any other way? I had read from books that the constructor property of object is inherited from its prototype. And the prototype can be changed dynamically. New property can be added to or deleted from object even it was created before the prototype change. But I got confused on below codes. Code: function A() { this.title = "A"; } function B() { this.title = "B"; } document.write("<br>"); var b = new B(); document.write(b.constructor); document.write("<br>"); document.write(B.prototype.constructor); document.write("<br>"); B.prototype = new A(); document.write(b.constructor); // Suppose to output "function A() ..." document.write("<br>"); document.write(B.prototype.constructor); document.write("<br>"); B.prototype.constructor = B; document.write(b.constructor); document.write("<br>"); document.write(B.prototype.constructor); document.write("<br>"); But the actual result (both IE and firefox) is Code: function B() { this.title = "B"; } function B() { this.title = "B"; } function B() { this.title = "B"; } function A() { this.title = "A"; } function B() { this.title = "B"; } function B() { this.title = "B"; } Please help me. thanks. Hello, I have the following object: Code: var layers = { photo1 : { index : 1, xPos : 63, yPos : 48, angle : 0 }, background : { index : 0, xPos : 278, yPos : 163, angle : 0 } } How can I sort the objects by the index property? Code: for(var layer in layers.sort(???)) { } Thx Very Much! I am and seem to remain newbie ... I have a JS script that presents a series of "pages" with different questions inside a single HTML file, by rewriting certain <div>s. I have an object like this that contains the questions and information about answer labels etc (the idea is that this should be easy to modify for someone who doesn't know JS): Code: var Questions = [ { "question" : "How good is this?", "labels" : ["excellent","very good","good","bad","very bad","awful"], "page" : 0 , "random" : false , "type" : "default", "varname" : "allgood" }, { "question" : Change[curCase]+"What do you think now?", "labels" : BetterLabels, "page" : 1 , "random" : true , "type" : "default", "varname" : "betteradapt" } ] This object is initialized when the page loads, and a function reads the total number of pages by getting the maximum number of the "page" property across elements. Later, the object is accessed by thenextQuestion() function which uses the "page" property to looks whether each element belongs on the current page , then reads out the properties and presents the question. This works okay. Now the tricky bit: For some questions, their text should be different depending on which case is currently on the screen (Change[curCase]). curCase is different on each page, an integer between 0 and Change.length. I cannot get this to work for the Questions object, probably because the Questions object has been already initialized when the page loaded. How can I get my function nextQuestion() to "re-evaluate" the property "question" for all the elements of the Questions objectwhen nextQuestion() is called , using the current value of "curCase"? nextQuestion() is longer, but the (i think!) crucial bits are he Look whether question belongs on current page and push it onto new array: Code: for (i=0; i < Questions.length; i++) { Questions[i].page = Questions[i].page; if ( Questions[i].page == BlockNum ) { // if the q belongs on the current page QuestionsObjectThisPage.push(Questions[i]); } } Then, extract an array containing the questions, which will then be presented: Code: for (i=0; i < QuestionsObjectThisPage.length; i++) { QuestionsThisPage.push(QuestionsObjectThisPage[i].question) ; } So what I'm looking for is something to change either of these two Object.push() functions so they don't simply take the value they find in the Questions (or QuestionsThisPage) object, but to re-evaluate the code for the "questions" property, taking into account the current value of curCase Phew. I found that really hard to describe; hope it's somewhat clear. I've got this JavaScript code that is doing stuff to the content of <TR> rows.. but it's overselecting and I need to filter the <TR>s it selects in the bold line. var theRows = document.getElementsByTagName("TR"); var r = 0; var strTitle = ""; while (r < theRows.length) { try { strTitle = theRows[r].innerText || theRows[r].textContent; strTitle = strTitle.replace(/\n|\r|\t|\^ /g,""); if (strTitle.substring(0,1) == "(") { if (strTitle.indexOf("STAT") == -1) { theRows[r].style.display = "none"; ... continues Below is the rendered html. What I really want to do instead of if (strTitle.substring(0,1) == "(") Is only perform the operation when a row that is using class="ms- formlabel, or maybe has a FieldInternalName. I understand that strTitle is just pulling content, so how do I condition on other properties or strings within the <TR> row given my currently logic? Rendered HTML. <TR> <TD nowrap="true" valign="top" width="190px" class="ms-formlabel"><H3 class="ms-standardheader"> <nobr>1. Do you become short of breath or develop chest pain when climbing a flight of stairs?</nobr> </H3></TD> <TD valign="top" class="ms-formbody" width="400px"> <!-- FieldName="1. Do you become short of breath or develop chest pain when climbing a flight of stairs?" FieldInternalName="ShortofBreath" FieldType="SPFieldBoolean" --> <span dir="none"> Thanks for any help or information! When I click on the image I want to get the "margin-left" value of its block. In the code below the margin-left is set at 100px. But when I click on the image the "margin-left" value shows in the "alert" as undefined. What code changes do I need to get the correct margin-left value? (Please, no guessing!) [CODE] <script type="text/javascript" > window.onload = function(){ document.getElementById("holder").onclick = showit; } function showit( ) { var marval = document.getElementById("holder").style.marginLeft; alert(" margin-left= " + marval + " typeof= " + typeof marval); } </script> <style type="text/css"> #holder{ padding: 0px; margin-left: 100px; } </style> </head> <body> <img id="holder" src="anyimage.gif" width="300px" height="200px" /> </body> [CODE] I am sorry the following code is a bit of a mouthful, but I can't find a better way to display the problem. The code works as expected in Chrome, but not in IE and FF. In IE the error is "Object doesn't support this action" and in FF "setting a property that has only a getter". In Chrome there is no error in the console. There are three javascript <script>...</script>s that exist to display a <td> row in a table with a particular graphic depending on the screen width. The odd thing is that in both IE and FF (and of course Chrome), the first two scripts display perfectly well. Why does the third <script> produce an error? It has exactly the same form as the two before it. I can only guess it has something to do with where it occurs Googling the FF error, it has something to do with trying to set a read-only property, but then why do the first two <scripts> work? They are no different (at least I can't see a difference.) Code: <table border="0" width="100%" cellpadding="0" style="border-collapse: collapse" id="table3768"> <script> if (screen.width > 1280) { document.write("<td valign=\"top\" background=\"..\/..\/img\/lesson2.gif\" width=\"840\" height=\"301\">"); } else { document.write("<td valign=\"top\" background=\"..\/..\/img\/lesson.gif\" width=\"369\" height=\"301\">"); } </script> <p> </p> <div align="left"> </table> <table border="0" style="border-collapse: collapse" cellpadding="15"> <tr> <td width="40"> </td> <script> if (screen.width > 1280) { document.write("<td width=\"300\">"); } else { document.write("<td width=\"165\">"); } </script> <font face="Trebuchet MS" color="#808000">Today's lesson is about setting goals...</font></td> </tr> </table> </div> </td> <td rowspan="3"> <table border="0" cellspacing="0" style="border-collapse: collapse" cellpadding="0" id="table3920"> <tr> <td><img border="0" src="../../img/teltopw.jpg" width="550" height="9"></td> </tr> <tr> <td background="../../img/telbarw.jpg"> <p align="center"> <iframe name="ITV" src="lesson1TV.html" marginwidth="0" marginheight="0" scrolling="no" border="0" frameborder="0" width="480" height="376"> Your browser does not support inline frames or is currently configured not to display inline frames. </iframe></p> </td> </tr> <tr> <td><img border="0" src="../../img/telbotw.jpg" width="550" height="11"></td> </tr> </table> </td> <td align="center"> <a rel="nofollow" target="_blank" href="http://www.apple.com/quicktime/download/"> <img border="0" src="../../img/quicktimeani.gif" width="129" height="184"></a></td> </tr> <tr> <script> if ((screen.width = 1440) || (screen.width = 1400)) { document.writeln("<td valign=\"top\" width=\"100%\" background=\"\/images\/101online\/listening\/lesson16\/notebot2.gif\" width=\"450\" height=\"50\">"); } else if (screen.width <= 1280) { document.writeln("<td valign=\"top\" width=\"100%\" background=\"\/images\/101online\/listening\/lesson16\/notebot.gif\" width=\"294\" height=\"50\">");; } </script> </td> <td valign="bottom"> </td> </tr> <tr> <td valign="bottom" width="100%"> <div align="right"> <table border="0" cellpadding="5" style="border-collapse: collapse" id="table3926"> <tr> <td align="center"> <a onmousedown="soundManager.play('piano','../../media/mp3/piano.mp3'); return true;" href="javascript: goFull('FULLSCREEN/lesson1full.html','info','width=1020,height=760,left=0,top=0,toolbar=no,scrollbars=no,status=no,directories=no,menubar=no,location=no,resizable=no');"> <img src="../../img/poster1ani.gif" border="0" width="95" height="29"></a> <b><font size="1" face="Arial" color="#000080"> ON DISK</font></b></td> <td align="center"><b><font size="1" face="Arial" color="#000080">OR </font></b> <a onmousedown="soundManager.play('piano','../../media/mp3/piano.mp3'); return true;" href="javascript: goFull('CDRIVE/lesson1Cfull.html','info','width=1020,height=760,left=0,top=0,toolbar=no,scrollbars=no,status=no,directories=no,menubar=no,location=no,resizable=no');"><img src="../../img/poster7.bmp" border="0" width="53" height="30"></a> <b><font size="1" face="Arial" color="#000080"> DRIVE</font></b></td> </tr> </table> </div> </td> <td valign="bottom"> <iframe name="sounds" src="../../pagesounds.html" width="160" height="66" marginwidth="1" marginheight="1" scrolling="no" border="0" frameborder="0"> Your browser does not support inline frames or is currently configured not to display inline frames. </iframe></td> </tr> </table> Any light on this would be most welcome! |