Ciao scusa ma riesco a rispondere solo adesso,
questa è la pagina completa di java riesci a darmi una mano, sono 3 gironi che impazzisco.
grazie ciao
Codice PHP:<?php
// impostazioni variabili
$og_html=array("nick","oggetto");
$fnome="./messaggi.txt";
// funzione controllo
function controllo() {
global $og_html, $_REQUEST;
foreach($og_html as $val) {
if(empty($_REQUEST[$val])) return false;
};
return true;
}
// controllo dati ricevuti
if(controllo()) {
// modifica dati
$nick=substr($_REQUEST["nick"],0,10);
$oggetto=substr($_REQUEST["oggetto"],0,60);
$nick=htmlspecialchars($nick);
$oggetto=htmlspecialchars($oggetto);
// apertura file
$file=file($fnome);
for($x=1; $x<count($file); $x++) $file_tmp[]=$file[$x];
$file_tmp[]="\n$nick: $oggetto";
$file=fopen($fnome,"w+");
fwrite($file,implode("",$file_tmp));
fclose($file);
};
// lettura file
$file=file($fnome);
// formattazione
unset($tmp_file);
for($x=0; $x<count($file); $x++) {
$file[$x]=addslashes(trim($file[$x],"\n"));
};
for($x=count($file)-1; $x>=0; $x--) $tmp_file[]=$file[$x];
// variabile da passare allo script
$cont_file=implode(" - ",$tmp_file);
?>
<html>
<head>
<title>Messaggi scorrevoli</title>
<style type="text/css">
<!--
a {
color:blue;
text-decoration:underline
}
a:hover {
color:red;
text-decoration:underline overline
}
body {
font:normal 1pc arial;
color:black
}
table#tab_cont td {
border:#000000 1px solid
}
input {
border:#000000 1px solid
}
-->
</style>
</head>
<body>
<table width="200" style="border:#000000 1px solid">
<tr><td>
<div id="frm">
<form method="post" action="<?php print($_SERVER["PHP_SELF"]); ?>" onsubmit="return valida(this);" style="padding:0px; margin:0px">
<table width="200">
<tr><td>Nick:</td><td><input type="text" name="nick"></td></tr>
<tr><td>Oggetto:</td><td><input type="text" name="oggetto"></td></tr>
<tr><td colspan="2" align="center"><input type="reset" value="Resetta"><input type="submit" value="Invia"></td></tr>
</table>
</form>
</div>
</td></tr>
<tr><td>
<script type="text/javascript">
<!--
var tempo=100;
var scroll=5;
var timer=null;
var timer_indietro=null;
var timer_avanti=null;
var scroll_vel=scroll+10;
// funzione valida
function valida(qst) {
var reg=new RegExp("^[ ]*$");
var chi=null;
try {
if(reg.test(qst.nick.value)) {
chi="nick";
throw "Non hai inserito il nick...";
};
if(reg.test(qst.oggetto.value)) {
chi="oggetto";
throw "Non hai inserito l'oggetto...";
};
}
catch(mes) {
window.alert(mes);
qst.elements[chi].focus();
return false;
};
return true;
};
// funzione init
function init() {
document.getElementById("mes_scor").style.left=document.getElementById("cont_mes").offsetWidth+"px";
document.getElementById("mes_scor").style.top="0px";
scrolla();
};
// funzione scrolla
function scrolla() {
if(parseInt(document.getElementById("mes_scor").style.left)>-(document.getElementById("mes_scor").offsetWidth+scroll)) {
document.getElementById("mes_scor").style.left=(parseInt(document.getElementById("mes_scor").style.left)-scroll)+"px";
}
else {
document.getElementById("mes_scor").style.left=document.getElementById("cont_mes").offsetWidth;
};
timer=window.setTimeout("scrolla();",tempo);
};
// funzione stop
function stop() {
clearTimeout(timer);
};
// funzione play
function play() {
if(window.timer) clearTimeout(timer);
window.setTimeout("scrolla();",tempo);
};
// funzione indietro
function indietro() {
if(parseInt(document.getElementById("mes_scor").style.left)<document.getElementById("cont_mes").offsetWidth) {
document.getElementById("mes_scor").style.left=parseInt(document.getElementById("mes_scor").style.left)+(scroll_vel);
}
else {
clearTimeout(timer_indietro);
};
timer_indietro=window.setTimeout("indietro();",tempo);
};
// funzione avanti
function avanti() {
if(parseInt(document.getElementById("mes_scor").style.left)>-(document.getElementById("mes_scor").offsetWidth+(scroll_vel))) {
document.getElementById("mes_scor").style.left=parseInt(document.getElementById("mes_scor").style.left)-(scroll_vel);
}
else {
clearTimeout(timer_avanti);
};
timer_avanti=window.setTimeout("avanti();",tempo);
};
document.write("<div id=\"cont\">");
document.write("<table width=\"200\" border=\"0\" id=\"tab_cont\">");
document.write("<tr><td align=\"center\"><a href=\"#\" onmousedown=\"if(window.timer) clearTimeout(timer); indietro();\" onmouseup=\"if(window.timer_indietro) clearTimeout(timer_indietro); play();\" tilte=\"Indietro\"><<</a></td><td align=\"center\"><a href=\"#\" onclick=\"stop();\" title=\"Stop\">||</a>|<a href=\"#\" onclick=\"play();\" title=\"Play\">>></a><td align=\"center\"><a href=\"#\" onmousedown=\"if(window.timer) clearTimeout(timer); avanti();\" onmouseup=\"if(window.timer_avanti) clearTimeout(window.timer_avanti); play();\" title=\"Avanti\">>></a></td></tr>");
document.write("<tr><td colspan=\"3\"><span id=\"cont_mes\" style=\"width:200px; position:relative; overflow:hidden\"><span id=\"mes_scor\" style=\"position:absolute; white-space:nowrap\"><?php print($cont_file); ?></span></span></td></tr>");
document.write("</table>");
document.write("</div>");
// funzione all'avvio
window.onload=init;
//-->
</script>
</td></tr>
</table>
</body>
</html>

Rispondi quotando