• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to return values jquery to javascript

#1
[eluser]JasmineFlower[/eluser]
Hi,

My javascript code is

Code:
function checkedSelectedProduct()
{    
    var ischk=document.getElementById('plant_li').checked;
        
        if(ischk)
        {
            var priceid=1;
            var pval=getprice(priceid);
            document.getElementById('plant_li_txt').value = pval;
            
        }
        else
        {
            document.getElementById('plant_li_txt').value = 0;
            document.getElementById('plant_li_txt').focus();
        }
}


function getprice(priceid)
{
    
     var url = base_url + "welcome/getsubscription_price/";
     $.post(   url    , { 'priceid': priceid }    , function(result)    { });
}

i want to return result value to function checkedSelectedProduct.

How?

#2
[eluser]JasmineFlower[/eluser]
Hi,

I found result

Code:
function checkedSelectedProduct()
{    
    var ischk=document.getElementById('plant_li').checked;
        
        if(ischk)
        {
            var priceid=1;
            var pval=getprice(priceid);
            document.getElementById('plant_li_txt').value = pval;
            
        }
        else
        {
            document.getElementById('plant_li_txt').value = 0;
            document.getElementById('plant_li_txt').focus();
        }
}

function getprice(priceid)
{    
    var priceval = $.ajax({
                       type: 'POST',
                    dataType: "request_type=generator",
                    url: base_url + 'welcome/getsubscription_price/' + Math.random(),
                    data: 'priceid=' + priceid,
                    
                    async: false
                       }).responseText;

        return priceval;            
}


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.