Jump to content

surveen

Members
  • Content Count

    10
  • Joined

  • Last visited

Community Reputation

0 Neutral

About surveen

  • Rank
    Member
  1. Hi, I have made changes like this in my script.js $(document).ready(function(){ /* The following code is executed once the DOM is loaded */ $(".todoList").sortable({ axis : 'y', // Only vertical movements allowed containment : 'window', // Constrained by the window update : function(){ // The function is called after the todos are rearranged // The toArray method returns an array with the ids of the todos var arr = $(".todoList").sortable('toArray'); // Striping the todo- prefix of the ids: arr = $.map(arr,function(val,key){ return val.replace('todo-',''); }); // Saving with AJAX $.get('ajax.php',{action:'rearrange',positions:arr}); }, /* Opera fix: */ stop: function(e,ui) { ui.item.css({'top':'0','left':'0'}); } }); // A global variable, holding a jQuery object // containing the current todo item: var currentTODO; // Configuring the delete confirmation dialog $("#dialog-confirm").dialog({ resizable: false, height:130, modal: true, autoOpen:false, buttons: { 'Delete item': function() { $.get("ajax.php",{"action":"delete","id":currentTODO.data('id')},function(msg){ currentTODO.fadeOut('fast'); }) $(this).dialog('close'); }, Cancel: function() { $(this).dialog('close'); } } }); // When a double click occurs, just simulate a click on the edit button: $('.todo').live('dblclick',function(){ $(this).find('a.edit').click(); }); // If any link in the todo is clicked, assign // the todo item to the currentTODO variable for later use. $('.todo a').live('click',function(e){ currentTODO = $(this).closest('.todo'); currentTODO.data('id',currentTODO.attr('id').replace('todo-','')); e.preventDefault(); }); // Listening for a click on a delete button: $('.todo a.delete').live('click',function(){ $("#dialog-confirm").dialog('open'); }); // Listening for a click on a edit button $('.todo a.edit').live('click',function(){ var container = currentTODO.find('.text'); if(!currentTODO.data('origText')) { // Saving the current value of the ToDo so we can // restore it later if the user discards the changes: currentTODO.data('origText',container.text()); } else { // This will block the edit button if the edit box is already open: return false; } $('<input type="text">').val(container.text()).appendTo(container.empty()); // Appending the save and cancel links: container.append( '<div class="editTodo">'+ '<a class="saveChanges" href="#">Save</a> or <a class="discardChanges" href="#">Cancel</a>'+ '</div>' ); }); // The cancel edit link: $('.todo a.discardChanges').live('click',function(){ currentTODO.find('.text') .text(currentTODO.data('origText')) .end() .removeData('origText'); }); // The save changes link: $('.todo a.saveChanges').live('click',function(){ var text = currentTODO.find("input[type=text]").val(); $.get("ajax.php",{'action':'edit','id':currentTODO.data('id'),'text':text}); currentTODO.removeData('origText') .find(".text") .text(text); }); // The Add New ToDo button: var timestamp=0; $('#addButton').click(function(e){ // Only one todo per 5 seconds is allowed: if((new Date()).getTime() - timestamp<3000) return false; $.get("ajax.php",{'action':'new','text':'New Todo Item. Doubleclick to Edit.','rand':Math.random()},function(msg){ // Appending the new todo and fading it into view: $(msg).hide().appendTo('#todoList').fadeIn(); $("#todoList").load( "index.php #todoList"); }); // Updating the timestamp: timestamp = (new Date()).getTime(); e.preventDefault(); }); }); // Closing $(document).ready() and in index.php <ul class="todoList" id="todoList"> But when i click on add, everything goes off , after refreshing it will appear again.
  2. Hello All, New Year Greetings!! I have integrated a script for TODO list in my website. Its working fine, but adding New task will be appear only after refreshing the page, whereas delete and save are happening as and when i click on them. I dont know where can i make it right. Here is my code Display <div class="w-box-content todo-list"> <ul class="todoList"> <?php require "todo.class.php"; $query = mysql_query("SELECT * FROM `tz_todo` ORDER BY `position` ASC"); $todos = array(); while($row = mysql_fetch_assoc($query)){ $todos[] = new ToDo($row); } foreach($todos as $item){ echo $item; } ?> </ul> <a id="addButton" class="green-button" href="#">Add a ToDo</a> <div id="dialog-confirm" title="Delete TODO Item?">Are you sure you want to delete this TODO item?</div> I am including <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/themes/humanity/jquery-ui.css" type="text/css" media="all" /> <link rel="stylesheet" type="text/css" href="styles.css" /> <script type="text/javascript" src="script.js"></script> and in ajax.php require "connect.php"; require "todo.class.php"; $id = (int)$_GET['id']; try{ switch($_GET['action']) { case 'delete': ToDo::delete($id); break; case 'rearrange': ToDo::rearrange($_GET['positions']); break; case 'edit': ToDo::edit($id,$_GET['text']); break; case 'new': ToDo::createNew($_GET['text']); break; } } catch(Exception $e){ // echo $e->getMessage(); die("0"); } echo "1";
  3. I have used GROUP_CONCAT() and DISTINCT and it worked for me. Thanks for your time
  4. Thanks for the solutions Barand. I will make sure that from next time i will try to explain my query in detail. I will try for location thing. Thank you
  5. Barand, actually even the locations are also multiple . suppose products are 2 and locations will be 3, that time its displays 3 times
  6. I am attaching the screenshot of my output, As there is multiple locations and multiple products for that supplier, it displays all the information as many a times. instead of that i want to display only one time with all the products, as comma seperated
  7. I have stored supplier information in a table and same form user will select multiple products for that supplier and that will be stored in a seperate table against that supplier id. Now when i would like to display all supplier information with muliple products in a single line. Now all the information will be displayed as many time as the products are. How to display all the products in a same line. Now my display is like this if(isset($_POST['submit']) && ($_POST['vendor']!='') && ($_POST['item']!='')) { $sql="SELECT supplier.id AS sid, supplier.name AS SNAME, supplier.category, supplier.website, supplier.email, supplier.phone, supplier.vat, supplier.pan, supplier_location.id, supplier_location.supplier_id, supplier_location.location, supplier_products.id, supplier_products.supplier_id, supplier_products.product_id, location.loc_id, location.name AS locname, products.product_id, products.name AS pname FROM supplier INNER JOIN supplier_location ON supplier.id = supplier_location.supplier_id INNER JOIN supplier_products ON supplier.id=supplier_products.supplier_id INNER JOIN location ON supplier_location.location = location.loc_id INNER JOIN products ON supplier_products.product_id=products.product_id WHERE supplier.id=".$sup." AND supplier_products.product_id=".$product; $sql1 = mysql_query($sql) or die(mysql_error()); <table> <thead><tr> <th>Vendor ID</th> <th>Vendor</th> <th>Category</th> <th>Website</th> <th>Email</th> <th>Phone</th> <th>Products</th> <th>Locations</th> <th>VAT</th> <th>PAN</th> </tr> </thead> <tbody> <tr> <?php while($row = mysql_fetch_array($sql1)) { ?> <td><?php echo $row['sid'] ?></td> <td><?php echo $row['SNAME'] ?></td> <td><?php echo $row['category'] ?></td> <td><?php echo $row['website'] ?></td> <td><?php echo $row['email'] ?></td> <td><?php echo $row['phone'] ?></td> <td><?php echo $row['iname']; ?></td> <td><?php echo $row['locname']; ?></td> <td><?php echo $row['vat'] ?></td> <td><?php echo $row['pan'] ?></td> </tr> <?php } ?> </tbody></table> }
×
×
  • 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.