last day (14 days later) » 

1:44 PM
1
A: HTML page that save its content, replacing the HTML file itself

CiroRa<html> <head> <title>Button Writer</title> </head> <body onload="read()"> <!--<button onclick="writeInFile()">Save</button> --> <input type="button" id="somebutton" onclick="addText()"> <input type="text" id="myText" placeholder="Enter Name Here"> ...

 
Yes please CiroRa! But the problem with PHP is that i dont have any server running on the Server side, it's the Jenkins unix Server so, it will be a mess to deploy an application, is there any Lightwheight solution to assume..
 
Node.js provides a lot of function. What do you think to install on your server? nodejs.org/en/download
 
Ok wait, i've this running on the server: [build@REMJenkinsServer01 ~]$ php --version PHP 5.3.3 (cli) (built: Sep 10 2014 05:27:26) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
Can you be so gentle to guide me through the step to do, I'm quite intuitive about these stuff, but its a little bit delicated server so i don't have the possiblity to proceed as i use to do "playing around..
Everything work... i just think that you miss the write part :)
 
have you solved?
 
Not yet, it works, but it does not do what i want... First i think the read is un-useful, i don't need it, i meant i just have to write directly to the php file when save it, and then maybe call a refresh of the page...Are you able to help more? Or should i walk on my feet now?
 
1:44 PM
have you decided to introduce PHP? the read is necessary to load content from file, there is no way to write without installing some other stuff....
 
Ok, could you help to guide my through this...? I got to update some div into the page and then rewrite to the server html/php page... So imagine, you have something like three row of a table, you can access to the page, and add information in a div or an input in these row, click a button to save the information and when someone will open the page from another client, he should see the information updated...Can you help me with this?
Hey you are so gentle!
 
I can, but since you're a back-end dev you should know that the best and fastest way is through PHP + MySql. A select to read and a form to add your data and save with an INSERT
 
yep, but i cant use a db..
listen just a second
i think my idea should work..
what about:
go in the url, its an internal one
see the rows
or one of them...
change them
then click a save button...
now this save button should just read the actual content of the page and write it into the same origin file... whats the problem here?
 
we have no methods to change them (to save a file via JS)
 
php
i made it now
like this
 
1:48 PM
ok, it's simpler now
 
1 <?php
2 ob_start();
3 ?>
47 <?php
48 file_put_contents('yourpage.html', ob_get_contents());
49 ?>
but i need the actual live content, not the origin one...
the actual injected html injected values
 
you have to pass it via ajax
wait a sec
 
and thats the part unknown to me... THANKS A MILLION!
where do you come from?
 
italy
 
Allora siamo compari :)
Sono Napoletano :)
 
1:51 PM
ahahah perfetto
salerno
 
XD XD
pero lavoro a dublino
 
ho una cosa del genere già pronta la recupero dal server e te la mando
 
sei grande!
davvero :)
 
tra na 10ina di minuti te lo mando, mi devo ricordare qual è
per mostrare il file semplicemente faccio <?php include('FileCommenti.html');?> dove filecommenti.html è il file dove salvo le varie cose
 
si si vai tranquillo
io intanto sto provando
a continuare da solo...chissa
 
1:59 PM
ok, quali sono i dati da inserire nel file, puoi farlo tramite form html?
dammi un esempio di come vuoi che i dati appaiano e te lo faccio al volo se riesco
<?php
session_start();
$n=$_SESSION['name'];
$cm=$_SESSION["feedback"];
$email=$_SESSION["email"];echo $_SERVER['REQUEST_URI'];
$data=date('d-m-Y');
$ourFileName = "FileCommenti.html";
$ourFileHandle = fopen($ourFileName, 'a') or die("can't open file");
$stringa="

<!--- INIZIO COMMENTO --> <li class='comment'><div class='comment-container'><header class='comment-header'><strong class='comment-author'> $n</strong><span class='comment-published'><time datetime='2012-03-22T21:57:02Z' title='2012-03-22 22:57' data-datetime='calendar'>$data</time></span></header><div class='comment-body markdow
 
mmhh..
 
praticamente metti nella tua pagina principale quell'include che ti ho scritto sopra cosi ti mostri i dati
 
in che senso i dati..
asp... t facc capire
 
cosa mostri?
fammi un disegno e te li intabello
o ti spiego il fatto e lo fai tu, è semplice
 
io ho gia tutto..
a livello grafico
ma come te lo passo?
nn posso upploadare file..
asp
 
2:05 PM
perfetto, allora quello che ti ho mandato va già bene
 
ti faccio vedere un immagine..
nn ce form
asp un sec soo
 
ok
 
ma cmq posso appezzottare
 
come sempre :D
 
:) :)
io ho questo
ci sara un sorta di spunta..
ed alla fine di ogni riga un button
ora se chi accede all pagina clikka su uno dei tasti
alla destra delle righe..
la spunta sara selezionata
 
2:07 PM
ahhh ok avevo capito che volessi solo aggiungere in coda
 
in poche parole chi ha fatto il task clikka completo e la riga viene aggiornata
ora il probl... e che questa operazione deve persistere sul server e modificare il contenuto della pagina di origine..
ad esempio un tag hidden diventa visibile o semplicemente un inejct d un html ecc ecc
mi disp forse nn mi ero spiegato prima..
ora pero apparte tutto questo che chiaramente mi devo piangere io..
il mio problema principale e solo salvare la pagina
sovrascriverla con i valori correnti
 
ho capito, la modifica del file (anziché di un append) è una palla perché devi capire dove andare a modificare i dati
 
no pero
asp...
 
però molto più semplicemente riprendiamo tutto il file cancelliamo il vecchio e scriviamo il nuovo
 
e un bagno di sangue
e bravo
perche devo modificare solo una parte
questo dicevo
basta che faccio la replace della vecchia con la nuova...
dovrebbe essere una funzioncina del cavolo.. pero fino ad ora nn ci arrivo :(
 
2:11 PM
ok allora vediamo se riesco a spiegartelo cosi mi dici se va bene.
questo arriva, apre la pagina e se la trovo caricata
modifica qualcosa e tu lo riscrivi nel file.
Giusto?
 
s
clikka su save
 
nella tua pagina, quella da mostrare all'utente, basta mettere questo .... <?php include('FileCommenti.html');?> dove FileCommenti.html è il tuo file che conterrà la tabella
ora passiamo a salvare il file (dopo che lui avrà modificato qualcosa). Finora ci sei?
 
abbastanzamente
pero....
perche nn usare sempre solo una pagina
io ho un file report.php
rappresenta l unica pagina da qui sara costituita l applicazione
dentro ce quello che hai visto
 
aspè mo te lo faccio!
 
modifico, completo le pagine e salvo...
ua... sei un santo
 
2:23 PM
crea un file che si chiama salva.php
e mettici questo
<?php


$stringa=$_POST['data'];

$ourFileName = "file.html";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fwrite($ourFileHandle,$stringa);
fclose($ourFileHandle);


?>
crea un file che chiami file.html e mettici questo <table border="2">
<tbody><tr><td>CIAO</td><td>CIAO1</td></tr>
</tbody></table>
crea un file che si chiama prova.php e mettici questo <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<div id="myText">


<?php include('file.html');?>

CIAO
</div>

<script>
var newData=document.getElementById("myText").innerHTML;
alert(newData);
$.post( "salva.php", { data: newData} );

</script>
quando hai fatto me lo dici
il pc si sta scaricando se riesci in breve riesco a spiegartelo
 
corro
scsami
mi hanno occupato un sec
CMQ GRAZIE ANCORA!
 
figurati, lo dico per te, mi restano 20 min di batteria
 
ce la fo
in 5 L:_)
in 5 :
mmmhh
fatto pero nn capisco
devo chiamare prova giusto?
 
si
hai copiato? te lo spiego perché comunque questo serve solo come bozza
 
si si
tuttop
e mi aggiunge in append ciao
 
2:38 PM
perfetto
io mo ho scritto ciao
 
si si
l alert s puo evita?
 
certamente
 
perfetto
soto tutto orecchie
 
tu invece di ciao, dopo che hai fatto tutte le tue modifiche le metti nella variabile e stai apposto. ti prendi l'innerHTML come stavi facendo già e hai finito
ah, ti devo mettere il bottone per salvare. aspè
 
ahaha grazie..
l unica cosa, andando in append
nn dovrebbe andare in replace?
 
2:40 PM
non va in append
il file lo apre in "w"
cancella e scrive
 
mmhh.. ma mi aggiunge sempre ciao giu..
cmq penso
funzioni alla grande
 
<button onclick="save()">SALVA</button>

<script>


function save(){

var newData=document.getElementById("myText").innerHTML;
$.post( "salva.php", { data: newData} );
}
</script>
 
devo solo modificarlo secondo le mie esigenze....
 
mo in prova.php lo metti cosi
esattamente, mo quello che devi fare è prenderti i cambiamenti sulle varie righe
 
1 <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
2 <div id="myText">
3 <?php include('file.html');?>
4 <button onclick="save()">SALVA</button>
5 <script>
6
7
8 function save(){
9
10 var newData=document.getElementById("myText").innerHTML;
11 $.post( "salva.php", { data: newData} );
12 }
13 </script>
cosi
 
2:42 PM
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<div id="myText">


<?php include('file.html');?>

CIAO
</div>

<button onclick="save()">SALVA</button>

<script>


function save(){

var newData=document.getElementById("myText").innerHTML;
$.post( "salva.php", { data: newData} );
}
</script>
sotto a CIAO il </div> lo devi lasciare
il CIAO non è che lo appende, solo che caricando dal file e poi scrivendo ti da la sensazione che appende ma non è cosi
 
ok ok..
grandissimo
 
altri dubbi?
 
grazie ciro..
non credo
devo solo modificare tutto
 
figurati
 
asseconda di come va
davvero troppo gentile
 
2:44 PM
mo lo pubblico e poi mi fai sapere
 
GRAZIEEEEEEE
 
ha segnato l'italia se ti interessa :)
 
uaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
sto in streaming
 
ah mettimi la spunta come risposta corretta. Grazie
 
CHIARO
 
2:48 PM
ciao
ok aggiunto
 
Grazie 1000 Ciro! per l ennessima volta... ma te li meriti
 
figurati ciao, e spunta CIAOoooooooooo
 

last day (14 days later) »