Get javascript active when posting php ajax result through javascript

gerardo_fp

New Member
I have this html form:\[code\] <form method="post"> <input type="radio" name="news" id="new" value="http://stackoverflow.com/questions/14544976/nuova" onchange="newstype(this.id);">Nuova News <input type="radio" name="news" id="mod" value="http://stackoverflow.com/questions/14544976/modifica" onchange="newstype(this.id);">Modifica News <select name="news" id="modifica" style="display:none" onchange="shownews(this.value)"> <?php include "../flock/sql.php"; $connection = new mysqli($host, $user, $pw, $db) or die("Impossibile connettersi"); $querylistanews = "SELECT * FROM NEWS ORDER BY id DESC"; $listanews = $connection->query($querylistanews); print '<option>Seleziona una news...</option>'; while ($newsdamodificare = $listanews->fetch_object()) { print '<option value="'.$newsdamodificare->id.'">'.$newsdamodificare->data." - ".$newsdamodificare->title.'</option>'; } $listanews->close(); $connection->close; ?> </select> </form>\[/code\]this javascript:\[code\]function newstype(param) { if(param == 'new') { document.getElementById('crea').style.display = 'inline'; document.getElementById('modifica').style.display = 'none'; document.getElementById('newsdamodificare').style.display = 'none'; } else { if(param == 'mod') { document.getElementById('crea').style.display = 'none'; document.getElementById('modifica').style.display = 'inline'; document.getElementById('newsdamodificare').style.display = 'inline'; } }}function shownews(str) { if (str=="") { document.getElementById("newsdamodificare").innerHTML=""; return; } if (window.XMLHttpRequest) { // codice per IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // codice per IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("newsdamodificare").innerHTML=xmlhttp.responseText; } }xmlhttp.open("GET","modifica.php?news="+str,true);xmlhttp.send();}\[/code\]and this php:\[code\]<head><script type="text/javascript" src="http://stackoverflow.com/questions/editor/ckeditor.js"></script><script type="text/javascript" src="http://stackoverflow.com/js/charscounter.js"></script></head><?php$news=$_GET["news"];include "../flock/sql.php";$connection = new mysqli($host, $user, $pw, $db) or die('Impossibile connettersi al database: ' . mysql_error());$newsdaldatabase="SELECT * FROM NEWS WHERE id = '".$news."'";$result = $connection->query($newsdaldatabase);$count = mysqli_num_rows($result);if($count==1){ while($dati = mysqli_fetch_array($result)) { $id = $dati['id']; $data = http://stackoverflow.com/questions/14544976/$dati['data']; $title = $dati['title']; $body = $dati['body']; }} else { die('Errore del sistema. Pi
 
Back
Top