Harjutuse lisamise-salvestamise näide: erinevus redaktsioonide vahel

Allikas: Lambda
Mine navigeerimisribale Mine otsikasti
Uus lehekülg: ' <html> <head><title>Lisamine</title> </head> <body> <script src="jquery.js" type="text/javascript"> </script> <script type="text/javascript"> function...'
 
Resümee puudub
79. rida: 79. rida:
       <input type="submit" value="Salvesta">
       <input type="submit" value="Salvesta">
     </form>
     </form>
 
     <div id="debug">
     <div id="debug">
 
     </div>
     </div>
 
     <table id="todolist">
     <table id="todolist">
     </table>
     </table>
 
   </body>
   </body>
  </html>
  </html>

Redaktsioon: 19. aprill 2012, kell 10:22

<html>
 <head><title>Lisamine</title>
 </head>
 <body>
   <script src="jquery.js" type="text/javascript">
   </script>
   <script type="text/javascript">

     function editTodo (index) {
       $("#debug").html(index);
       
     }

     function renderTodoCallback( todolist, textStatus, jqXHR) {

       $("#debug").html("");

var tablecontent = "NameDesc\n";

       for (i = 0; i < todolist.length; i++) {

tablecontent += "\n" + todolist[i].f0 + "
\n"; tablecontent += "" + todolist[i].f1 + "\n"; tablecontent += "<a href=\"javascript:editTodo(" + todolist[i].id + ");\">Muuda</a>\n\n"; tablecontent += "\n"; } $("#todolist").html(tablecontent); } function renderTodo() { $.getJSON("http://dijkstra.cs.ttu.ee/~irve/cgi-bin/ui3/otsi.py?table=t0&salvestaja=test@example.ee", renderTodoCallback); } function addTodoCallback(sendstatus, textStatus, jqXHR) { if (sendstatus == 0) { $("#debug").html("Error with saving entry. Sorry about that."); return; } renderTodo(); } function addTodo() { /* add checking */ var url="http://dijkstra.cs.ttu.ee/~irve/cgi-bin/ui3/salvesta.py?table=t0&"; url += "salvestaja=" + $("#salvestaja").val(); url += "&f0=" + $("#todoname").val(); url += "&f1=" + $("#tododesc").val(); $("#debug").html(url); $.getJSON(url, addTodoCallback ); return false /* don't send the form using normal means */ } $(document).ready( function() { renderTodo(); }); </script> <form onsubmit="return addTodo();"> <input id="salvestaja" type="text" placeholder="Salvestaja" value="test@example.ee">
<input id="todoname" type="text" placeholder="Title">
<input id="tododesc" type="text" placeholder="Description">
<input type="submit" value="Salvesta"> </form>

 </body>
</html>