Jump to content

faces3

Members
  • Posts

    31
  • Joined

  • Last visited

faces3's Achievements

Member

Member (2/5)

0

Reputation

  1. Yes I try it but give same error. http://workhour.tk/silmaring/regkool/
  2. Undefined index: $item_id ajax.php on line 8
  3. Error invalid JSON: and give ajax.php file
  4. That script i get that site. http://www.amitpatil.me/ajax-table-adding-removing-rows-dynamically-using-javascript-animation/ Seems there is more people who cant get work it.
  5. Here is my database. -- phpMyAdmin SQL Dump -- version 3.5.4 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: May 01, 2013 at 10:11 PM -- Server version: 5.1.67 -- PHP Version: 5.3.3 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Database: `silmaring` -- -- -------------------------------------------------------- -- -- Table structure for table `kool` -- CREATE TABLE IF NOT EXISTS `kool` ( `nr` time NOT NULL, `kool` varchar(50) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
  6. Looks ['action'] is right. File: script.js $(document).ready(function(){ $("#save").click(function(){ ajax("save"); }); $("#add_new").click(function(){ $(".entry-form").fadeIn("fast"); }); $("#close").click(function(){ $(".entry-form").fadeOut("fast"); }); $("#cancel").click(function(){ $(".entry-form").fadeOut("fast"); }); $(".del").live("click",function(){ ajax("delete",$(this).attr("id")); }); function ajax(action,id){ if(action =="save") data = $("#userinfo").serialize()+"&action="+action; else if(action == "delete"){ data = "action="+action+"&item_id="+id; } $.ajax({ type: "POST", url: "ajax.php", data : data, dataType: "json", success: function(response){ if(response.success == "1"){ if(action == "save"){ $(".entry-form").fadeOut("fast",function(){ $(".table-list").append("<tr><td>"+response.kool+"</td><td><a href='#' id='"+response.row_id+"' class='del'>Delete</a></a></td></tr>"); $(".table-list tr:last").effect("highlight", { color: '#4BADF5' }, 1000); }); }else if(action == "delete"){ var row_id = response.item_id; $("a[id='"+row_id+"']").closest("tr").effect("highlight", { color: '#4BADF5' }, 1000); $("a[id='"+row_id+"']").closest("tr").fadeOut(); } }else{ alert(response.msg); } }, error: function(res){ alert("Unexpected error! Try again."); } }); } }); Website give me same error what is here... "Unexpected error! Try again."
  7. I add that is it right? I dont see errors... error_reporting(E_ALL); ini_set('display_errors', '1'); And i add that line: $action = $_POST['action']; But seems it dont work. What i must put there ['action'] Or is it right?
  8. I try get work that script, but something is wrong... Cant save new values and cant delete values. <html> <head> <title>Silmaring</title> <script src="js/jquery.js"></script> <script src="js/script.js"></script> <script src="js/jquery-ui-1.8.17.custom.min.js"></script> <link rel="stylesheet" href="css/style.css"> </head> <body> <br> <div style="margin-left: 20%;margin-top: 5%;"> <input type="button" value="Lisa" id="add_new"><p> <table width="70%" border="0" cellpadding="0" cellspacing="0" class="table-list"> <tr> <th width="20%">Kooli nimi</th> <th width="40%">Kustuta</th> </tr> </table> </div> <div class="entry-form"> <form name="userinfo" id="userinfo"> <table width="100%" border="0" cellpadding="4" cellspacing="0"> <tr> <td colspan="2" align="right"><a href="#" id="close">Sulge</a></td> </tr> <tr> <td>Kooli nimi</td> <td><input type="text" name="kool"></td> </tr> <tr> <td align="right"></td> <td><input type="button" value="Salvesta" id="save"><input type="button" value="Tühista" id="cancel"></td> </tr> </table> </form> </div> </body> </html> And here is ajax.php file. <? ini_set('display_errors',1); ini_set('display_startup_errors',1); error_reporting(-1); $conn = mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("silmaring",$conn) or die(mysql_error()); if(isset($_POST) && count($_POST)){ $kool = $_POST['kool']; $item_id = $_POST['$item_id']; if($action == "save"){ $res = mysql_query("insert into kool values('','".$kool."')"); if($res){ echo json_encode( array( "success" => "1", "row_id" => time(), "kool" => htmlentities($kool), ) ); } } else if($action == "delete"){ $res = mysql_query("delete from info where id = $"); if($res){ echo json_encode( array( "success" => "1", "item_id" => $item_id ) ); } } }else{ echo "No data set"; } ?> I turn error messages on, but dont see any errors.
  9. <code><html xmlns="http://www.w3.org/1999/xhtml"><head profile="http://gmpg.org/xfn/11"> <head> <title>Dynamically Add Remove Textboxes Using Jquery</title> <script type="text/javascript" src="jquery-1.5.2.min.js"></script> <script src="jquery-ui.min.js"></script> <style type="text/css"> body{ font-family:arial; color:#666; } form input{ border:2px solid #dadada; border-radius:7px; font-size:20px; padding:5px; width:250px; } input:focus { outline:none; border-color:#9ecaed; box-shadow:0 0 10px #9ecaed; } form .button{ background: -moz-linear-gradient(top, #00b7ea 21%, #009ec3 76%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(21%,#00b7ea), color-stop(76%,#009ec3)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, #00b7ea 21%,#009ec3 76%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, #00b7ea 21%,#009ec3 76%); /* Opera 11.10+ */ background: -ms-linear-gradient(top, #00b7ea 21%,#009ec3 76%); /* IE10+ */ background: linear-gradient(to bottom, #00b7ea 21%,#009ec3 76%); /* W3C */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00b7ea', endColorstr='#009ec3',GradientType=0 ); /* IE6-9 */ color:#DFE9EC; border:none; cursor:pointer; padding:7px; } .txt_div{ float:left; width:300px; margin-bottom:10px; } .left{ float:left; width:250px; } .right{ float:right; width:40px; padding-top: 11px; } img{ cursor:pointer; } </style> <script type="text/javascript"> $(document).ready(function(){ var id = 2,max = 8,append_data; /*If the add icon was clicked*/ $(".add").live('click',function(){ if($("div[id^=txt_]").length <{ //Don't add new textbox if max limit exceed $(this).remove(); //remove the add icon from current text box var append_data = '<div id="txt_'+id+'" class="txt_div" style="display:none;"><div class="left"><input type="text" id="input_'+id+'" name="txtval[]"/></div><div class="right"><img src="add.png" class="add"/> <img src="remove.png" class="remove"/></div></div>'; $("#text_boxes").append(append_data); //append new text box in main div $("#txt_"+id).effect("bounce", { times:3 }, 300); //display block appended text box with silde down id++; } else { alert("Maximum 8 textboxes are allowed"); } }) /*If remove icon was clicked*/ $(".remove").live('click',function(){ var prev_obj = $(this).parents().eq(1).prev().attr('id'); //previous div id of this text box $(this).parents().eq(1).slideUp('medium',function() { $(this).remove(); //remove this text box with slide up if($("div[id^=txt_]").length > 1){ append_data = '<img src="remove.png" class="remove"/>'; //Add remove icon if number of text boxes are greater than 1 }else{ append_data = ''; } if($(".add").length < 1){ $("#"+prev_obj+" .right").html('<img src="add.png" class="add"/> '+append_data); } }); }) }); </script> </head> <body> <div style="width:800px; margin:auto;padding-top:100px;"> <h1>Dynamically Add Remove Textboxes Using Jquery</h1> <form id="form" name="form"> <div id="text_boxes" style="width:300px;height:auto;"> <div id="txt_1" class="txt_div"> <div class="left"> <input type="text" id="input_1" name="txtval[]"/> </div> <div class="right"> <img src="add.png" class="add"/> </div> </div> </div> <div style="clear:left;"></div> <input type="button" value="SUBMIT" class="button" onclick="javascript:alert($('#form').serialize());"> </form> </div> </body> </html></code>
  10. http://demo.blogaddition.com/dynamic_textbox/
  11. How add one more input value and save same row database two values. Like this: Name: [Textbox1] Values: [Textbox2][textbox2] [add new] [submit] Create new table in database and table name is "Textbox1" values. And save that new table one row "textbox2" and "textbox3" values. Here is code link how must it look like:) Thanks for help!
  12. http://demo.blogaddition.com/dynamic_textbox/
  13. Just like here, but open two input fields and how to save it database new row.
  14. I need have only one line input field. and have button "add new input line in form" And then open new line and there is two input field. And all input field line save new row in database.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.