style.display='block' is not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • WSPL5
    New Member
    • Apr 2007
    • 5

    style.display='block' is not working

    I have a hidden span within a table column and I cannot unhide it using style.display=' block' ??

    Sample code
    <table>
    <tr>
    <td><input name="status" value=""></td><td><input type="button" value="search" onClick="search ByStatus()"></td>
    <td><div id="MySpan" Style="display: none"><img src="ajaxprogre ssindicator.gif "></div></td>
    </tr>
    </table>

    var xmlHttp = new ActiveXObject(" MSXML2.XMLHTTP" );
    function searchByStatus( ){
    var f=document.form s[0];
    var key =f.status.value ;
    if(key==''){
    alert("Please select a status");
    return;
    }
    MySpan.style.di splay='block';
    var url = "/"+document.form s[0].getdbpath.valu e+"/StatusSearch?Op enAgent";
    pdata="&a="+key ;
    xmlHttp.open("P OST",url,false) ;
    xmlHttp.setRequ estHeader("Cont ent-type","applicat ion/x-www-form-urlencoded");
    xmlHttp.setRequ estHeader("Cont ent-length",pdata.l ength);
    xmlHttp.setRequ estHeader("Conn ection","close" );
    xmlHttp.onready statechange = processSearchXM L
    xmlHttp.send(pd ata)
    }
    I have used a similar method in the past. the location of the span, inside or outside of the table does not seem to matter.
    I have got the image to appear by placing an alert after the line:
    MySpan.style.di splay='block';.
    Maybe this has something to do with a small result set, but in the past with only one result I still saw the image flicker and in this case I am returning over 25 results from the server.
  • lilOlMe
    New Member
    • May 2007
    • 74

    #2
    Originally posted by WSPL5
    I have a hidden span within a table column and I cannot unhide it using style.display=' block' ??
    ...
    I have got the image to appear by placing an alert after the line:
    MySpan.style.di splay='block';.
    Maybe this has something to do with a small result set, but in the past with only one result I still saw the image flicker and in this case I am returning over 25 results from the server.

    Have you tried :
    [code=javascript]
    document.getEle mentByID('MySpa n').style.visib ility = 'visible';
    [/code]
    or
    [code=javascript]
    document.getEle mentByID('MySpa n').style.displ ay = 'block';
    [/code]

    I think you need to use the getElementByID( ) method and set the style that way.

    -LilOlMe

    Comment

    • WSPL5
      New Member
      • Apr 2007
      • 5

      #3
      Yes, I tried document.getEle mentById('MySpa n').style.displ ay='block' as well as document.all['MySpan'].style.display= 'block';.
      The way I call the span does not seem to have an effect.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        If the result comes back very fast, is there a problem?

        I think that you should use visibility instead so that the page layout doesn't change, but that depends on how the page is.

        Comment

        Working...