mardi 26 juillet 2016

Place jquery result in an input field

i am getting the result of a total in a <p> i would like the get the same result in an input field. Here is my code.

HTML

<select id="selector" onChange="Expedisi(this);">
            <option>Select product</option>
          <optgroup label="Sedan">
            <option value="Lancer EX">Lancer EX 1.6 / 2.0</option>
            <option value="Lancer EX GT">Lancer EX GT</option>
          <optgroup label="Sport">
            <option value="Lancer Evolution X">Lancer Evolution X</option>
          <optgroup label="SUV">
            <option value="Outlander">Outlander</option>
        </select>

<p id="thetotal"> </p>

JavaScript

$('#selector').on('change', function() {
    total = data[$(this).val()].price;

    $('#thetotal').text("" + total);
})

Aucun commentaire:

Enregistrer un commentaire