Web Analytics Made Easy -
StatCounter displaying php output into div - CodingForum

Announcement

Collapse
No announcement yet.

displaying php output into div

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • displaying php output into div

    I thought I knew how, but I'm unclear how to get this function to display: "document.getElementById("txtHint").innerHTML=xmlhttp.responseText;" inside the div. Will you show me please?

    Code:
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 && xmlhttp.status==200) {
          var div = document.createElement('div');
          div.setAttribute('id', 'txtHint');
          div.setAttribute("style","background-color:red;");
          div.style.width = '300px';
          div.style.height = '100px';
          document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
          //var txt='hello world!';
          document.getElementsByTagName('body')[0].appendChild(div);
          document.getElementById('textHint').innerHTML=txt;
        }
      }

  • #2
    I worked it out. Here's my solution:
    Code:
    if (xmlhttp.readyState==4 && xmlhttp.status==200) {
    	  var div = document.createElement('div');
          div.setAttribute('id', 'link_container');
          div.setAttribute("style","background-color:white;");
          div.style.width = '300px';
          div.style.height = '100px';
          div.style.margin = '-15px 0px 0px 75px';
          var txt=document.innerHTML=xmlhttp.responseText;
          document.getElementsByTagName('body')[0].appendChild(div);
          document.getElementById('link_container').innerHTML=txt;
        }

    Comment


    • #3
      Code:
      xmlhttp.onreadystatechange=function() {
          if (xmlhttp.readyState==4 && xmlhttp.status==200) {
            var div = document.createElement('div');
            div.setAttribute('id', 'txtHint');
            div.setAttribute("style","background-color:red;");
            div.style.width = '300px';
            div.style.height = '100px';
      [COLOR="Red"]      div.innerHTML=xmlhttp.responseText;
      [/COLOR]      document.getElementsByTagName('body')[0].appendChild(div);
          }
        }
      Though instead of doing
      Code:
            div.setAttribute("style","background-color:red;");
            div.style.width = '300px';
            div.style.height = '100px';
      why not do
      Code:
            div.className = "MyBigFatRedDiv";
      and set up the style in your CSS?
      Be yourself. No one else is as qualified.

      Comment


      • #4
        Thank-you very much. You answered a couple questions that I've been meaning to ask. How very Zen of you.

        Comment

        Working...
        X
        😀
        🥰
        🤢
        😎
        😡
        👍
        👎