vendredi 30 janvier 2015

How to pass value from change function?

I don't have Idea how to pass a value from change function, for example i have function like this :



$('pilihan').change(function(){
var amount = $('#pilihan option:selected').val();
var result = amount*12; });


I want pass value of "result" variable to other function just like this :



function add() {
var lastresult = result+56;
$('#jumlah').text(lastresult);


If I do this, then variable "result" in add function doesn't has value.


So, how to pass result variable value from change function to other function?





Aucun commentaire:

Enregistrer un commentaire