Tuesday 28 August 2012

How to call Java script function inside Jquery

How to call Java script  function inside Jquery



<script type="text/javascript"> 
 function prodd(id){
  }          

jQuery(document).ready(function(){

prodd = function(id) {
document.getElementById(id).style.visibility = 'hidden'; 
  var id = $("#pdId").val();
  var dataString = 'id='+ id;
  $.ajax
  ({
  type: "POST",
  url: '<?php echo site_url('sellerInventory/delete');?>',
  data: 'id='+ id,
  cache: false,
  success: function(html)
  {
 
  }
  });
  
 };
// Call Jquery function inside jquery Script:
 var addproductM = function(name,id)
   {
   var MURL = $("#MURL").val();
    var strHTML="";
  strHTML+='<div class="confirmationproducts" onclick="prodd(this.id);" id="I';
  strHTML += id;
  strHTML += '">';
  strHTML+='<div class="cpproduct">';
  strHTML+=name;
  strHTML+='</div>';
  strHTML += '<input type="hidden" id="pdId" value="';
  strHTML += id;
  strHTML += '">';
  strHTML+='<div class="cpdelet id="de"><a class="linkdelete" id=""  href="#"></a></div>';
  strHTML+='<div class="clear-both"></div></div>';
$(".prod").html(strHTML);

var price = $('#price').val();
var catId = $('#cId').val();
var locally = $("input[name=locally]:checked").val();
var organic = $("input[name=organic]:checked").val();
var stocknow = $("input[name=stocknow]:checked").val();
var homeDe = $("input[name=homeDe]:checked").val();
var priceNote = $('#priceNote').val();
//Multiple data submission to ajax request
var data = "id="+id+"&locally="+locally+"&organic="+organic+"&stocknow="+stocknow+"&homeDe="+homeDe+"&priceNote="+priceNote+"&price="+price+"&catId="+catId;
$.ajax
  ({
  type: "POST",
  url: MURL,
  data: data,
  cache: false,
  success: function(html)
  {
 
  }
  });
$.fallr('hide');
   }
$('.linktype').click(function () {

var currentAnchor = $(this);
    var id = currentAnchor.attr('id');
    var name = currentAnchor.attr('name');
    var light = $('#url').val();
    var dataString = 'id='+ id;
$.ajax
({
type: "POST",
url: light,
data: dataString,
cache: false,
success: function(data)
{
var gap     = 20;
var boxH    = $(window).height() - gap;     // bottom gap
var boxW    = $(window).width() - gap * 2;  // left + right gap
$.fallr('show', {
   content : data,
   width   : boxW,
   height  : boxH,
   buttons : {
       button1 : { text: 'Add Product',onclick :function(){addproductM(name,id);}},
       button2 : { text: 'Cancel'}
   },
   
}); 
},
});
    });





});
});





No comments:

Post a Comment