Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-07-2004, 01:48 PM   PM User | #1
sgalmeida
New Coder

 
Join Date: Jan 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
sgalmeida is an unknown quantity at this point
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>
<?
}
?>
sgalmeida is offline   Reply With Quote
Old 01-07-2004, 01:52 PM   PM User | #2
A1ien51
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
A1ien51 will become famous soon enough
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]
A1ien51 is offline   Reply With Quote
Old 01-07-2004, 02:39 PM   PM User | #3
sgalmeida
New Coder

 
Join Date: Jan 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
sgalmeida is an unknown quantity at this point
Hi,
can ou be a bit more specific abou the innerHTML?


Thanks

Sérgio
sgalmeida is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:34 AM.


Advertisement
Log in to turn off these ads.