Use a variable from a function in another function on javascript

26 views Asked by At

I want to use this function variable sacopa

function show_selected() {
    var selector = document.getElementById('id_of_select');
    var copa = selector[selector.selectedIndex].value;
    var sacopa = parseInt(copa);
};

on this other function

function shuma1() {
    vlera1=0;
    var x = document.getElementById('width').value / 100;
    var z = document.getElementById('height').value /100;
    var value1 = x*4*5;
    var value2 = z*4*5;
    var value3 = x*z
    var vlera = value1 + value2 + 15 + value3 * 25 * sacopa;
    document.getElementById('result').value = vlera.toFixed(1) + "€";
    vlera1=vlera;
};
0

There are 0 answers