Welcome Guest, Not a member yet? Register   Sign In
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;            
}




Theme © iAndrew 2016 - Forum software by © MyBB