Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. <form id="form-product-info" data-parsley-validate class="form-horizontal form-label-left">
  2. <div class="form-group">
  3. <label class="control-label col-md-3 col-sm-3 col-xs-12" for="product-SKU">SKU <span class="required">*</span>
  4. </label>
  5. <div class="col-md-6 col-sm-6 col-xs-12">
  6. <input type="text" id="product-SKU" required="required" class="form-control col-md-7 col-xs-12" value="<?php echo $results[0]->SKU; ?>">
  7. </div>
  8. </div>
  9.  
  10. <div class="ln_solid"></div>
  11. <div class="form-group">
  12. <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
  13. <button class="btn btn-primary" type="button" id="btn-customer-list">Cancel</button>
  14. <button class="btn btn-danger" type="button" id="btn-delete-product">Delete</button>
  15. <button type="submit" class="btn btn-success source">Submit</button>
  16. </div>
  17. </div>
  18.  
  19. </form>
  20.  
  21. public function updateProductInformation()
  22. {
  23. $product_information['name'] = $this->input->post('name');
  24. $product_information['SKU'] = $this->input->post('SKU');
  25. $product_information['product_id'] = $this->input->post('id');
  26.  
  27. $product_information['last_updated'] = date('Y-m-d H:i:s');
  28.  
  29. var_dump($product_information);
  30. $update = $this->updateProductInformation($product_information);
  31.  
  32. $this->update($update);
  33. }
  34.  
  35. $('#form-product-info').submit(function() {
  36. alert('Submitting form');
  37. var id = $('#product-name').data('product-id');
  38. updateProductInformation(id);
  39. });
  40.  
  41. function updateProductInformation(id)
  42. {
  43. alert('Updating product information ' + id);
  44. var name = $('#product-name').val();
  45. var SKU = $('#product-SKU').val();
  46. alert(name);
  47. alert(SKU);
  48. alert(id);
  49.  
  50. $.ajax({
  51. type: 'post',
  52. url: base_url + 'product/updateProductInformation',
  53. data: {
  54. 'name' : name,
  55. 'SKU' : SKU,
  56. 'id' : id
  57. },
  58. success: function(msg)
  59. {
  60. if (msg == 'true')
  61. {
  62. alert('Updating product information successful');
  63. }
  64. else
  65. {
  66. alert("Please try again. ");
  67. }
  68. },
  69. error: function(jqXHR, textStatus, errorThrown)
  70. {
  71. console.log('Response text: ' + jqXHR.responseText);
  72. console.log('Status code: ' + textStatus);
  73. console.log('Error thrown: ' + errorThrown);
  74. }
  75. });
  76. }
  77.  
  78. array(4) { ["name"]=> NULL ["SKU"]=> NULL ["product_id"]=> NULL ["last_updated"]=> string(19) "2017-09-23 10:07:20" }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement