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 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript and dynamic DIV display

    Greetings,

    I have a PHP function that outputs a Javascript function that verifies if a certain field is a digit or not. I want to, if it is not a digit, a DIV is shown with a custom message (is prettier than an JS alert). If I do this the way you can see bellow, I loose the page I was seeing; on source page I see only the DIV from isDigito(valor,campo) uutput. How can I do to not loose the rest of the page?
    How can I do, using Javascript, do display DIV without loosing the rest of the page?

    Thanks
    Sérgio


    <?
    function JS_isDigito(){
    ?>
    <script LANGUAGE='JavaScript'>
    <!-- Begin
    function isDigito(valor,campo){
    var digits='0123456789'
    var temp

    for (var i=0;i<valor.value.length;i++){
    temp=valor.value.substring(i,i+1)
    if (digits.indexOf(temp)==-1){
    /*alert("O campo '"+campo+"' deve ser preenchido apenas com números!")
    valor.value=""
    valor.focus()
    */

    document.write("<div id=\"Alert\" style=\"position:absolute; width:300px; height:141px; z-index:1; overflow: hidden; left: 357px; top: 354px; visibility: visible;\"> ");
    document.write("<table width=\"300\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
    document.write("<tr>");
    document.write("<td><img src=\"img/AlertTopo.gif\" width=\"300\" height=\"15\"></td>");
    document.write("</tr>");
    document.write("</table>");
    document.write("<table width=\"300\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"img/AlertMeio.gif\">");
    document.write("<tr>");
    document.write("<td height=\"30\"><div align=\"center\"><? echo $GLOBALS['divAlertMinutesText']; ?></div></td>");
    document.write("</tr>");
    document.write("<tr>");
    document.write("<td height=\"30\"><div align=\"center\">");
    document.write("<input name=\"Submit22\" type=\"submit\" class=\"op\" onClick=\"MM_showHideLayers('Alert','','hide')\" value=\"Fechar\">");
    document.write("</div></td></tr><tr> <td>&nbsp;</td></tr></table>");
    document.write("<table width=\"300\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
    document.write("<tr> <td><img src=\"img/AlertBaixo.gif\" width=\"300\" height=\"15\"></td>");
    document.write("</tr></table></div>");


    return false
    }
    }
    return true;
    }
    // End -->
    </script>
    <?
    }
    ?>

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    You can not document.write after tha page is loaded.

    What you need to do is have the divs already there when the page loads and use innerHTML to change the content of the div.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New Coder
    Join Date
    Jan 2004
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,
    can ou be a bit more specific abou the innerHTML?


    Thanks

    Sérgio


  •  

    Posting Permissions

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