javascript error (dynamic table generation)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #16
    What error do you get now?

    Please use the proper code tags when posting code. To use code tags, use the # button. You can specify the language using =javascript in the opening code tag, e.g. [code=javascript].

    Comment

    • yoshimishu
      New Member
      • Feb 2008
      • 29

      #17
      Originally posted by acoder
      What error do you get now?

      Please use the proper code tags when posting code. To use code tags, use the # button. You can specify the language using =javascript in the opening code tag, e.g. [code=javascript].
      I am not getting any error but the the value inside <div> codes is not changing on pressing the button in new window.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #18
        Change line 22 to:
        [code=javascript]nwin.document.w rite("<input type='button' value='get details' onclick=\"docum ent.getElementB yId('ScriptDiv' ).innerHTML = window.opener.s r();\" >");[/code]Remember that sr() is in the parent page, so to access it, you need to use window.opener.

        Comment

        • yoshimishu
          New Member
          • Feb 2008
          • 29

          #19
          Originally posted by acoder
          Change line 22 to:
          [code=javascript]nwin.document.w rite("<input type='button' value='get details' onclick=\"docum ent.getElementB yId('ScriptDiv' ).innerHTML = window.opener.s r();\" >");[/code]Remember that sr() is in the parent page, so to access it, you need to use window.opener.
          I had tried it ealier with window.opener.s r() but it was not displaying the value returned by the function.

          Comment

          • yoshimishu
            New Member
            • Feb 2008
            • 29

            #20
            Originally posted by yoshimishu
            I had tried it ealier with window.opener.s r() but it was not displaying the value returned by the function.
            I am getting crazy with this thing man this dummy code is taking so much time then how long will the origional code take.

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #21
              Originally posted by yoshimishu
              I had tried it ealier with window.opener.s r() but it was not displaying the value returned by the function.
              Did you replace line 22 with the code that I posted earlier? You forgot the (escaped) quotes.

              Comment

              • yoshimishu
                New Member
                • Feb 2008
                • 29

                #22
                Originally posted by acoder
                Did you replace line 22 with the code that I posted earlier? You forgot the (escaped) quotes.
                the sample code is runnign properly and the main program is also running fine but it has some problem. when i call this function it displays table with :-
                [CODE=javascript]function sr(v)
                {
                var n = xmlDoc.document Element.childNo des[0].getElementsByT agName("item"). item(v);
                var disp="<table width='90%' bgcolor='pink' border='1'>"
                disp+="<tr><td> "+n.childNo des[3].text+"</tr></td>"
                disp+="<tr><td> "+n.childNo des[4].text+"</tr></td>"
                disp+="<tr><td> <a href=\""+n.chil dNodes[1].text+"\">"+n.c hildNodeS[1].text+"</tr></td>"
                disp+="</table>"
                return disp;
                }
                [/CODE]

                but whrn I edit it with the following coe it shows up fourth row but with a undefined value:-
                [CODE=javascript]function sr(v)
                {
                var n = xmlDoc.document Element.childNo des[0].getElementsByT agName("item"). item(v);
                var rm = xmlDoc.getEleme ntsByTagName("d escription").it em(v+1);
                var disp="<table width='90%' bgcolor='pink' border='1'>"
                disp+="<tr><td> "+n.childNo des[3].text+"</tr></td>"
                disp+="<tr><td> "+n.childNo des[4].text+"</tr></td>"
                disp+="<tr><td> <a href=\""+n.chil dNodes[1].text+"\">"+n.c hildNodes[1].text+"</tr></td>"
                disp+="<tr><td> "+rm.text+" </td></tr>"
                disp+="</table>"
                return disp;
                }
                [/CODE]

                thanks;
                Last edited by acoder; Feb 9 '08, 08:33 AM. Reason: fixed code tags

                Comment

                • yoshimishu
                  New Member
                  • Feb 2008
                  • 29

                  #23
                  Originally posted by yoshimishu
                  the sample code is runnign properly and the main program is also running fine but it has some problem. when i call this function it displays table with :-
                  [CODE=javascript ]function sr(v)
                  {
                  var n = xmlDoc.document Element.childNo des[0].getElementsByT agName("item"). item(v);
                  var disp="<table width='90%' bgcolor='pink' border='1'>"
                  disp+="<tr><td> "+n.childNo des[3].text+"</tr></td>"
                  disp+="<tr><td> "+n.childNo des[4].text+"</tr></td>"
                  disp+="<tr><td> <a href=\""+n.chil dNodes[1].text+"\">"+n.c hildNodeS[1].text+"</tr></td>"
                  disp+="</table>"
                  return disp;
                  }
                  [/CODE]

                  but whrn I edit it with the following coe it shows up fourth row but with a undefined value:-
                  [CODE=javascript]function sr(v)
                  {
                  var n = xmlDoc.document Element.childNo des[0].getElementsByT agName("item"). item(v);
                  var rm = xmlDoc.getEleme ntsByTagName("d escription").it em(v+1);
                  var disp="<table width='90%' bgcolor='pink' border='1'>"
                  disp+="<tr><td> "+n.childNo des[3].text+"</tr></td>"
                  disp+="<tr><td> "+n.childNo des[4].text+"</tr></td>"
                  disp+="<tr><td> <a href=\""+n.chil dNodes[1].text+"\">"+n.c hildNodes[1].text+"</tr></td>"
                  disp+="<tr><td> "+rm.text+" </td></tr>"
                  disp+="</table>"
                  return disp;
                  }
                  [/CODE]

                  thanks;
                  I have edited this code.Its still not workink

                  Comment

                  • yoshimishu
                    New Member
                    • Feb 2008
                    • 29

                    #24
                    Originally posted by yoshimishu
                    I have edited this code.Its still not workink
                    final code is working on IE after editing the line 4 to[CODE=javascript]
                    var rm = xmlDoc.getEleme ntsByTagName("d escription").it em(++v);[/CODE]
                    code shows an error in FireFox

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #25
                      Originally posted by yoshimishu
                      final code is working on IE after editing the line 4 to[CODE=javascript]
                      var rm = xmlDoc.getEleme ntsByTagName("d escription").it em(++v);[/CODE]
                      code shows an error in FireFox
                      What's the error message?

                      Comment

                      • yoshimishu
                        New Member
                        • Feb 2008
                        • 29

                        #26
                        Originally posted by acoder
                        What's the error message?
                        xmlDoc.document Element.childNo des[0].getElementsByT agName is not a function
                        [Break on this error] var it=xmlDoc.docum entElement.chil dNodes[0].getElementsByT agName("item");

                        Comment

                        • acoder
                          Recognized Expert MVP
                          • Nov 2006
                          • 16032

                          #27
                          Originally posted by yoshimishu
                          xmlDoc.document Element.childNo des[0].getElementsByT agName is not a function
                          [Break on this error] var it=xmlDoc.docum entElement.chil dNodes[0].getElementsByT agName("item");
                          This is usually caused by whitespace. You're assuming that the first child childNodes[0] is not a whitespace (IE ignores whitespace). See this link for more information.

                          Comment

                          • yoshimishu
                            New Member
                            • Feb 2008
                            • 29

                            #28
                            Originally posted by acoder
                            This is usually caused by whitespace. You're assuming that the first child childNodes[0] is not a whitespace (IE ignores whitespace). See this link for more information.
                            I need to change the entire synatx i.e use code like if(nodeType!=1) or there is an shorter way.

                            Comment

                            • acoder
                              Recognized Expert MVP
                              • Nov 2006
                              • 16032

                              #29
                              Originally posted by yoshimishu
                              I need to change the entire synatx i.e use code like if(nodeType!=1) or there is an shorter way.
                              Remove the whitespace in your XML.

                              Comment

                              • yoshimishu
                                New Member
                                • Feb 2008
                                • 29

                                #30
                                Originally posted by acoder
                                Remove the whitespace in your XML.
                                Hey I am getting the code right in FF but IE shows some error when I add this line:
                                [CODE=javascript] disp+="<tr><td> Author</td><td>"+n.getE lementsByTagNam eNS("http://purl.org/
                                dc/elements/1.1/","creator" )[0].firstChild.nod eValue+"</tr></td>"[/CODE]

                                IE says document does not support this property.

                                Comment

                                Working...