Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Sep 2008
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts

    updating element values in IE7

    I want to update the innerHTML of an element with data that I have gotten from an xml. First of all this all works in FF3 but not in IE7.

    for the html element I have tried both:
    <p id="fullday" class="news"></p> (preferred)
    and
    <div id="fullday" class="news"></div>

    I want to update the text of fullday.
    The Javascript I have tried:

    document.getElementById("fullday").innerHTML = fullday; (where fullday is a string with the text I want)

    also I have tried
    var el = document.createElement('p');
    document.getElementById('fullday').appendChild(el);
    el.innerHTML = fullday;
    (where fullday is a div)
    and

    var el = document.createElement('p');
    el.innerHTML = fullday;
    document.getElementById('fullday').appendChild(el);

    All of these have worked beautifully in FF and not one has worked in IE

  • #2
    Senior Coder
    Join Date
    Oct 2008
    Location
    Long Beach
    Posts
    1,196
    Thanks
    36
    Thanked 164 Times in 164 Posts
    Those all work in both browsers, the problem lies elsewhere (probably in how you pull and assign your xml). If you post the rest of your code, we might be able to help.
    Feel free to e-mail me if I forget to respond ;)
    ohsosexybrit@gmail.com

  • #3
    New Coder
    Join Date
    Sep 2008
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I thought of that and tried updating with a simple "Hello World!" string and it still didn't work. In any case here's the code:

    function stateChanged() {
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
    var xmlDoc=xmlHttp.responseXML.documentElement;
    var fullday = "Today's Master Torah Learning is available for dedication";
    var amudyomi = "Today's Amud Yomi Learning is available for dedication";
    var shasreview = "Today's Shas Review Learning is available for dedication";
    var mishna = "Today's Mishna Learning is available for dedication";
    var rambam = "Today's Rambam Learning is available for dedication";
    var allShas = "";
    var allMishna = "";
    var none = xmlDoc.hasAttribute("none");
    if(!none) {
    for(j=1;j<xmlDoc.childNodes.length;j++) {
    var dedication = xmlDoc.childNodes[j];
    var donor = dedication.getElementsByTagName("donor")[0];
    if(donor.getAttribute("display") == 1)
    var dedicator = donor.firstChild.nodeValue+" Dedicated ";
    else
    var dedicator = "Dedication of ";

    var receiver = dedication.getElementsByTagName("receiver")[0];
    var dedicated = "";
    for(i=0;i<receiver.childNodes.length;i++) {
    var ded = receiver.childNodes[i];
    var tn = ded.tagName;
    var tv = ded.firstChild.nodeValue;
    if(i>0 && i<receiver.childNodes.length) dedicated += ", and";
    if(tn == "yartzeit") dedicated += " for the Yartzeit of "+tv;
    if(tn == "shloshim") dedicated += " for the Shloshim of "+tv;
    if(tn == "memory") dedicated += " in Memory of "+tv;
    if(tn == "honor") dedicated += " in Honor of "+tv;
    if(tn == "occasion") dedicated += " on the Occasion of "+tv;
    if(tn == "other") dedicated += tv;
    }
    var learning = dedication.getElementsByTagName("learning")[0];
    for(i=0;i<learning.childNodes.length;i++) {
    var lrn = learning.childNodes[i];
    var tn = lrn.tagName;
    var tv = lrn.firstChild.nodeValue;
    if(tn == "fullday" && tv == 1) fullday = dedicator+"Today's Master Torah Learning"+dedicated;
    if(tn == "amudyomi" && tv == 1) amudyomi = dedicator+"Today's Amud Yomi Learning"+dedicated;
    if(tn == "shasreview" && tv == 1) shasreview = dedicator+"Today's Shas Review Learning"+dedicated;
    if(tn == "mishna" && tv == 1) mishna = dedicator+"Today's Mishna Learning"+dedicated;
    if(tn == "rambam" && tv == 1) rambam = dedicator+"Today's Rambam Learning"+dedicated;
    if(tn == "allShas" && tv == 1) allShas = dedicator+"All of Talmud Bavli"+dedicated;
    if(tn == "allMishna" && tv == 1) allMishna = dedicator+"All of Mishna"+dedicated;
    }
    }
    }

    var el = document.createElement('p');
    document.getElementById('fullday').appendChild(el);
    el.innerHTML = fullday;
    var e = document.getElementById("amudyomi");
    if(e != null)
    e.innerHTML=amudyomi;
    e = document.getElementById("shasreview");
    if(e != null)
    e.innerHTML=shasreview;
    e = document.getElementById("talmud");
    if(e != null)
    e.innerHTML=amudyomi+"<br />"+shasreview;
    e = document.getElementById("mishna");
    if(e != null)
    e.innerHTML=mishna;
    e = document.getElementById("rambam");
    if(e != null)
    e.innerHTML=rambam;
    document.getElementById("allShas").innerHTML=allShas;
    document.getElementById("allMishna").innerHTML=allMishna;
    }
    }

    thanks for your help in advance.

  • #4
    Senior Coder
    Join Date
    Oct 2008
    Location
    Long Beach
    Posts
    1,196
    Thanks
    36
    Thanked 164 Times in 164 Posts
    Nothing jumps out at me as being incompatible with IE, however since I don't have your XML to test, why don't you show me your "hello world" example code that doesn't work - I'll try to fix that.

    As proof that your original post code works cross-browser, here's a simple innerHTML example:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Example</title>
    <style type="text/css">
    </style>
    <script type="text/javascript">
    // <![CDATA[
    
    window.onload = function()
    	{
    	var my_id = "hey";
    	document.getElementById("my_id").innerHTML = my_id;
    	}
    
    // ]]>
    </script>
    </head>
    <body>
    
    <div id="my_id"></div>
    
    </body>
    </html>
    Feel free to e-mail me if I forget to respond ;)
    ohsosexybrit@gmail.com

  • #5
    New Coder
    Join Date
    Sep 2008
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Here's a example of my xml:

    <?xml version='1.0' encoding='ISO-8859-1'?>
    <dedications >
    <date>19 Kislev 5769</date>
    <dedication>
    <donor display="1">The Proud Father</donor>
    <receiver>
    <honor>Our Baby Girl</honor>
    </receiver>
    <learning>
    <fullday>1</fullday>
    <amudyomi>1</amudyomi>
    <shasreview>0</shasreview>
    <mishna>1</mishna>
    <rambam>0</rambam>
    <allShas>0</allShas>
    <allMishna>0</allMishna>
    </learning>
    </dedication>
    <dedication>
    <donor display="0">Dovid</donor>
    <receiver>
    <memory>the fallen of Mumbai</memory>
    <occasion>Displaying the Dedications</occasion>
    </receiver>
    <learning>
    <fullday>0</fullday>
    <amudyomi>0</amudyomi>
    <shasreview>0</shasreview>
    <mishna>0</mishna>
    <rambam>1</rambam>
    <allShas>1</allShas>
    <allMishna>1</allMishna>
    </learning>
    </dedication>
    </dedications>

  • #6
    New Coder
    Join Date
    Sep 2008
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    btw, how do you get it to format when posting?

  • #7
    Senior Coder
    Join Date
    Oct 2008
    Location
    Long Beach
    Posts
    1,196
    Thanks
    36
    Thanked 164 Times in 164 Posts
    Use [ code][ /code] and [ quote][ /quote].

    why don't you show me your "hello world" example code that doesn't work - I'll try to fix that.
    Feel free to e-mail me if I forget to respond ;)
    ohsosexybrit@gmail.com

  • Users who have thanked itsallkizza for this post:

    fruminovator (12-17-2008)

  • #8
    New Coder
    Join Date
    Sep 2008
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    you inspired me to do a comment out and find the offending line, which I did.

    apparently IE does not like the node.hasAttribute() function. So I changed it to getAttribute() and now if works.

    Thanks so much for your help.

  • #9
    Senior Coder
    Join Date
    Oct 2008
    Location
    Long Beach
    Posts
    1,196
    Thanks
    36
    Thanked 164 Times in 164 Posts
    Anytime, though I don't feel like I helped all that much... lol
    Feel free to e-mail me if I forget to respond ;)
    ohsosexybrit@gmail.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •