Using Output From Two Drop Down Lists To Create Text In Multiple Places
I have several drop down lists as follows:
Solution 1:
Here is a jquery solution:
$(function() {
var firstValue = $('#dropdown').val();
var secondValue = $('#dropdown2').val();
$('#labelOne').text(firstValue);
$('#labelTwo').text(secondValue);
$('#total').text(firstValue * secondValue);
$('#dropdown').on('change', function(){
firstValue = $('#dropdown').val();
$('#labelOne').text(firstValue);
$('#total').text(firstValue * secondValue);
});
$('#dropdown2').on('change', function(){
secondValue = $('#dropdown2').val();
$('#labelTwo').text(secondValue);
$('#total').text(firstValue * secondValue);
});
});
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><selectname="dropdown"id="dropdown"><optionvalue="1000">1000</option><optionvalue="2000">2000</option><optionvalue="3000">3000</option><optionvalue="4000">4000</option></select><selectname="dropdown2"id="dropdown2"><optionvalue="12">12</option><optionvalue="24">24</option><optionvalue="36">36</option><optionvalue="48">48</option></select><spanid="labelOne"></span> *
<spanid="labelTwo"></span> =
<spanid="total"></span>
Post a Comment for "Using Output From Two Drop Down Lists To Create Text In Multiple Places"