clearing div tags with a button using php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
awiedman
Forum Newbie
Posts: 7
Joined: Wed Sep 24, 2008 6:58 pm

clearing div tags with a button using php

Post by awiedman »

Hey,

I have a file called chatlogs.php and it has a div tag with chat logs in it and I been trying to delete all the text in that div tag with a button. I been trying it with javascript and when you hit the clear button it clears it but when you refresh it reappears. So is there a way to just all the text in that div tag permently on the file with php?
Last edited by awiedman on Wed Nov 26, 2008 10:59 am, edited 2 times in total.
mintedjo
Forum Contributor
Posts: 153
Joined: Wed Nov 19, 2008 6:23 am

Re: clearing div tags with a button using php

Post by mintedjo »

Post some more code and somebody might be able to help you.
Once a web page has been displayed in the browser you cant modify it with php.
Javascript is the right language to use for this, and it will work if its done correctly.
Post a bit of code so we can see what you were doing wrong.

Joe
awiedman
Forum Newbie
Posts: 7
Joined: Wed Sep 24, 2008 6:58 pm

Re: clearing div tags with a button using php

Post by awiedman »

This is the code i tried but it didn't erase it permently

Button:

Code: Select all

<button onclick="document.getElementById('logs').innerHTML = '&nbsp;'; ">Clear</button>
Div:

Code: Select all

<div id="logs">
mintedjo
Forum Contributor
Posts: 153
Joined: Wed Nov 19, 2008 6:23 am

Re: clearing div tags with a button using php

Post by mintedjo »

Code: Select all

it didn't erase it permently
You mean you want the text to disappear forever? and never ever show up again?

I may have misunderstood your original post. I thought you just wanted to change the contents of a div after it has been displayed - it looks like you know how to do that.

I'm not entirely sure what you are trying to do now.
If you can explain better then please do so otherwise i`m sorry i cant help. :-(
awiedman
Forum Newbie
Posts: 7
Joined: Wed Sep 24, 2008 6:58 pm

Re: clearing div tags with a button using php

Post by awiedman »

Ok all i want is a button for when you click it, it clear everything in the div tag permently.
because info from a server posts into the "logs" div section and i want to be able to clear everything in the div section with a "Clear Logs" button.

The only problem with i got below is it clears the div tag when you click the button, but when you refresh the page it reappears, so it basically didn't delete it.

What I got so far:

Code: Select all

<html>
<head>
 
<style>
.chat_log {
font-family: Arial;
font-size: 12px;
}
</style>
</head>
<body>
 
<center><h1><font face="Arial">Chat Logs</h1>
<hr noshade width="600"></center>
<center><button onclick="document.getElementById('logs').innerHTML = '&nbsp;'; ">Clear Chat Log</button></center>
<table align="center">
<tr><td>
<pre>
<div id="logs">
11/20/2008 17:11:16 {135} {0} {135} {0} {RoomChange} 
11/20/2008 17:11:16 {135} {10} {135} {10} {Logon} {HIECOODAA} {ZNGAEIGMBF} {Tiggy}
11/20/2008 17:11:20 {135} {10} {135} {10} {RoomChange} 
11/20/2008 17:11:22 {135} {12} {135} {12} {RoomChange} 
11/20/2008 17:11:26 {135} {114} {135} {114} {RoomChange} 
11/20/2008 17:12:05 {135} {734} {135} {734} {RoomChange} 
11/20/2008 17:12:09 {135} {114} {135} {114} {RoomChange} 
11/20/2008 17:15:44 {136} {894} {136} {894} {RoomChange} 
11/20/2008 17:15:46 {136} {893} {136} {893} {RoomChange} 
11/20/2008 17:17:21 {136} {899} {136} {899} {RoomChange} 
11/20/2008 17:17:21 {136} {893} {136} {893} {RoomChange} 
11/20/2008 17:17:24 {136} {894} {136} {894} {RoomChange} 
11/20/2008 17:17:27 {136} {893} {136} {893} {RoomChange} 
11/20/2008 17:44:21 {130} {912} {130} {912} {RoomChange} 
11/20/2008 17:44:37 {130} {893} {130} {893} {RoomChange} 
11/20/2008 17:44:53 {130} {894} {130} {894} {RoomChange} 
11/20/2008 17:44:58 {130} {893} {130} {893} {RoomChange} 
11/20/2008 17:45:08 {130} {678} {130} {678} {RoomChange} 
11/20/2008 17:45:10 {130} {893} {130} {893} {RoomChange} 
11/20/2008 17:49:15 {130} {446} {130} {446} {RoomChange} 
11/20/2008 17:49:17 {130} {893} {130} {893} {RoomChange} 
11/20/2008 18:29:02 {137} {0} {137} {0} {RoomChange} 
11/20/2008 18:29:02 {137} {10} {137} {10} {Logon} {HOEPHONPG} {ZNHOAOCHD} {Nicky}
11/20/2008 18:29:04 {137} {10} {137} {10} {RoomChange} 
11/20/2008 18:29:07 {137} {12} {137} {12} {RoomChange} 
11/20/2008 18:29:10 {137} {176} {137} {176} {RoomChange} 
11/20/2008 18:29:12 {137} {245} {137} {245} {RoomChange} 
11/20/2008 18:44:56 {138} {0} {138} {0} {RoomChange} 
11/20/2008 18:44:56 {138} {10} {138} {10} {Logon} {EFDFPEMIF} {ZPBPGGCIFA} {??l?Cl< ANG3L?}
11/20/2008 18:45:01 {138} {10} {138} {10} {RoomChange} 
11/20/2008 18:45:04 {138} {12} {138} {12} {RoomChange} 
11/20/2008 18:45:06 {138} {176} {138} {176} {RoomChange} 
11/20/2008 18:45:10 {138} {245} {138} {245} {RoomChange} 
11/20/2008 18:45:56 {138} {911} {138} {911} {RoomChange} 
11/20/2008 18:46:08 {138} {245} {138} {245} {RoomChange} 
11/20/2008 18:46:29 {138} {751} {138} {751} {RoomChange} 
11/20/2008 18:46:32 {138} {245} {138} {245} {RoomChange} 
11/20/2008 18:46:38 {138} {751} {138} {751} {RoomChange} 
11/20/2008 18:46:42 {138} {245} {138} {245} {RoomChange} 
11/20/2008 18:49:56 {138} {336} {138} {336} {RoomChange} 
11/20/2008 18:50:08 {138} {245} {138} {245} {RoomChange} 
11/20/2008 18:50:49 {138} {913} {138} {913} {RoomChange} 
11/20/2008 18:50:55 {138} {245} {138} {245} {RoomChange} 
11/20/2008 18:55:46 {139} {0} {139} {0} {RoomChange} 
11/20/2008 18:55:46 {139} {10} {139} {10} {Logon} {IBBGIDN} {ZNGOODEOEH} {??r??ity ??g??<3? ??m?(?)}
11/20/2008 18:55:49 {139} {10} {139} {10} {RoomChange} 
11/20/2008 18:55:53 {139} {12} {139} {12} {RoomChange} 
11/20/2008 18:55:58 {139} {893} {139} {893} {RoomChange} 
11/20/2008 18:56:03 {139} {1059} {-1} {1059} {Talk} clean
11/20/2008 18:57:38 {139} {1059} {-1} {1059} {Talk} 'accept
11/20/2008 18:58:30 {139} {1059} {-1} {1059} {Talk} 'accept
11/20/2008 18:59:05 {139} {1059} {139} {1059} {RoomChange} 
11/20/2008 18:59:08 {139} {893} {139} {893} {RoomChange} 
11/20/2008 19:00:42 {139} {977} {139} {977} {RoomChange} 
11/20/2008 19:00:44 {139} {893} {139} {893} {RoomChange} 
11/20/2008 19:02:08 {139} {989} {139} {989} {RoomChange} 
11/20/2008 19:02:09 {139} {893} {139} {893} {RoomChange} 
11/20/2008 19:03:43 {140} {0} {140} {0} {RoomChange} 
11/20/2008 19:03:43 {140} {10} {140} {10} {Logon} {EADIEBG} {ZAACOPIMAA} {[?i?rc? prez] ebullient ; em ?}
11/20/2008 19:03:46 {140} {10} {140} {10} {RoomChange} 
11/20/2008 19:03:48 {140} {12} {140} {12} {RoomChange} 
11/20/2008 19:03:53 {140} {893} {140} {893} {RoomChange} 
11/20/2008 19:04:09 {139} {990} {139} {990} {RoomChange} 
11/20/2008 19:04:11 {139} {893} {139} {893} {RoomChange} 
11/20/2008 19:06:24 {139} {991} {139} {991} {RoomChange} 
11/20/2008 19:06:26 {139} {893} {139} {893} {RoomChange} 
11/20/2008 19:06:41 {139} {992} {139} {992} {RoomChange} 
11/20/2008 19:06:43 {139} {893} {139} {893} {RoomChange} 
11/20/2008 19:08:28 {139} {899} {139} {899} {RoomChange} 
11/20/2008 19:08:32 {139} {893} {139} {893} {RoomChange} 
11/20/2008 19:08:34 {139} {12} {139} {12} {RoomChange} 
11/20/2008 19:08:42 {139} {176} {139} {176} {RoomChange} 
11/20/2008 19:08:44 {139} {245} {139} {245} {RoomChange} 
11/20/2008 19:12:33 {141} {0} {141} {0} {RoomChange} 
11/20/2008 19:12:33 {141} {10} {141} {10} {Logon} {FEHPAGEHH} {ZHBBEENIG} {a?h. ??jd??}
11/20/2008 19:17:41 {142} {0} {142} {0} {RoomChange} 
11/20/2008 19:17:41 {142} {10} {142} {10} {Logon} {FOABHBG} {ZMNNHNMFFF} {&jared.}
11/20/2008 19:17:46 {142} {10} {142} {10} {NameChange} v?b?; Baby.
11/20/2008 19:17:49 {143} {0} {143} {0} {RoomChange} 
11/20/2008 19:17:49 {143} {10} {143} {10} {Logon} {FOABHBG} {ZMNNHNMFFF} {v?b?; Baby.}
11/20/2008 19:38:55 {144} {0} {144} {0} {RoomChange} 
11/20/2008 19:38:55 {144} {10} {144} {10} {Logon} {NNGNGBG} {ZEPICOEDIG} {???@ngel????}
11/20/2008 19:39:12 {144} {10} {144} {10} {RoomChange} 
11/20/2008 19:39:15 {144} {11} {144} {11} {RoomChange} 
11/20/2008 19:39:17 {144} {12} {144} {12} {RoomChange} 
11/20/2008 19:39:47 {145} {0} {145} {0} {RoomChange}
 
User avatar
panic!
Forum Regular
Posts: 516
Joined: Mon Jul 31, 2006 7:59 am
Location: Brighton, UK

Re: clearing div tags with a button using php

Post by panic! »

Chatrooms are modern.
Post Reply