----- Original Message ----- From: "Tedit kap" hello, what i am trying to do is, after hitting the submit button in a form, the questions and the submit button should disappear and at the same place the results should show up. right now the form is posting to another page, which i dont know how to display at the same location of the form. i tried posting the form to itself but all it does is, it still continues to display the questions after submitting. please help. ------------------------------------ AJAX method -
------------- vote.htm -------------- <html> <head> <title> Vote Example page </title> </head> <body> <script> function vote(item) { item = "http://domainname.com/vote.php?vote=" + item; script = document.createElement('script'); script.src = item; head = document.getElementsByTagName('head').item(0); head.appendChild(script); } </script> <table width="100%"> <tr> <td align="center"><img width="120" height="90" src="" alt="Example image"></td> <td align="center"><img width="120" height="90" src="" alt="Example image"></td> <td align="center"><img width="120" height="90" src="" alt="Example image"></td> <td align="center"><img width="120" height="90" src="" alt="Example image"></td> </tr> <tr> <td align="center"><a href="" onclick='vote("1"); return false;'>Vote for item 1</a></td> <td align="center"><a href="" onclick='vote("2"); return false;'>Vote for item 2</a></td> <td align="center"><a href="" onclick='vote("3"); return false;'>Vote for item 3</a></td> <td align="center"><a href="" onclick='vote("4"); return false;'>Vote for item 4</a></td> </tr> <tr> <td align="center"><span id="vc1"></span></td> <td align="center"><span id="vc2"></span></td> <td align="center"><span id="vc3"></span></td> <td align="center"><span id="vc4"></span></td> </tr> </table> <br> <br> <center> Right click <a href="http://domainname.com/vote.php?vote=3">here</a> and select save as to download the Javascript from the server. <br> Your brower will not download it directly as it has a Javascript mime type. </center> </body> </html> ----------------------------- ------------- vote.php ---------------- <?php $vote=$_GET['vote']; $vote1=0; $vote2=0; $vote3=0; $vote4=0; if ($votefile=fopen('vote1.txt','r')); { $vote1=intval(fread($votefile,4095)); fclose($votefile); } if ($votefile=fopen('vote2.txt','r')); { $vote2=intval(fread($votefile,4095)); fclose($votefile); } if ($votefile=fopen('vote3.txt','r')); { $vote3=intval(fread($votefile,4095)); fclose($votefile); } if ($votefile=fopen('vote4.txt','r')); { $vote4=intval(fread($votefile,4095)); fclose($votefile); } if ($vote==1) { $vote1=$vote1+1; } if ($vote==2) { $vote2=$vote2+1; } if ($vote==3) { $vote3=$vote3+1; } if ($vote==4) { $vote4=$vote4+1; } $votefile=fopen('vote1.txt','w'); fwrite($votefile,strval($vote1)); fclose($votefile); $votefile=fopen('vote2.txt','w'); fwrite($votefile,strval($vote2)); fclose($votefile); $votefile=fopen('vote3.txt','w'); fwrite($votefile,strval($vote3)); fclose($votefile); $votefile=fopen('vote4.txt','w'); fwrite($votefile,strval($vote4)); fclose($votefile); header("Content-type: application/x-javascript"); header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 07 Aug 2006 05:00:00 GMT"); echo( 'document.getElementById("vc1").innerText="' . $vote1 . ' Votes";' . "\n"); echo( 'document.getElementById("vc2").innerText="' . $vote2 . ' Votes";' . "\n"); echo( 'document.getElementById("vc3").innerText="' . $vote3 . ' Votes";' . "\n"); echo( 'document.getElementById("vc4").innerText="' . $vote4 . ' Votes";' . "\n"); ?>