I have a form in which certain calculations are happening as per the dropdown selected. Everything is working fine except that when i select a value from dropdown price/unit field has to be filled by calculating (total1/qty) which is returning NaN. Pls help on this? My markup is below:
<html>
<head>
<title>Dept</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.10.1.js'></script>
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$(document).ready(function(){
$("select").on('change',function () {
var dept_number = $(this).val();
var price = $(this).find(':selected').data('price');
$(this).closest('table').find('.deptip').val(dept_number);
$(this).closest('table').find('.priceip').val(price);
$(this).closest('table').find('.total1').val(price * $(this).closest('table').find('.total').data('value'));
$(this).closest('table').find('.price_unit').val($(this).closest('table').find('.total1').data('value') / $(this).closest('table').find('.qty').data('value'));
});
});
});//]]>
</script>
</head>
<body>
<div class="base"> <!--Keep each group in base container-->
<table border="1"><tr>
<td><select id="category0">
<option value="1" data-price="10">USD</option>
<option value="2" data-price="20">INR</option>
<option value="3" data-price="30">AUD</option>
</select></td>
<td><label>Dept. num:</label>
<input type="text" class="deptip" id="dept-input"/><!--give them a class--></td>
<td><label>Price:</label>
<input type="text" class="priceip" id="price-input"/> <!--a class here too--></td>
<td><label>Total:</label><input data-value="50" type="text" readonly class="total" value="50"/></td>
<td><label>Qty:</label><input type="text" class="qty" value="5"/></td>
<td><label>Total1:</label><input data-value="50" type="text" readonly class="total1"/></td>
<td><label>Price/Unit:</label><input type="text" readonly class="price_unit" /></td>
</tr></table>
</div>
<div class="base"> <!--Keep each group in base container-->
<table border="1"><tr>
<td><select id="category1">
<option value="1" data-price="10">USD</option>
<option value="2" data-price="20">INR</option>
<option value="3" data-price="30">AUD</option>
</select></td>
<td><label>Dept. num:</label>
<input type="text" class="deptip" id="dept-input"/><!--give them a class--></td>
<td><label>Price:</label>
<input type="text" class="priceip" id="price-input"/> <!--a class here too--></td>
<td><label>Total:</label><input data-value="50" type="text" readonly class="total" value="50"/></td>
<td><label>Qty:</label><input type="text" class="qty" value="5" /></td>
<td><label>Total1:</label><input data-value="50" type="text" readonly class="total1"/></td>
<td><label>Price/Unit:</label><input type="text" readonly class="price_unit"/></td>
</tr></table>
</div>
<div class="base"> <!--Keep each group in base container-->
<table border="1"><tr>
<td><select id="category2">
<option value="1" data-price="10">USD</option>
<option value="2" data-price="20">INR</option>
<option value="3" data-price="30">AUD</option>
</select></td>
<td><label>Dept. num:</label>
<input type="text" class="deptip" id="dept-input"/><!--give them a class--></td>
<td><label>Price:</label>
<input type="text" class="priceip" id="price-input"/> <!--a class here too--></td>
<td><label>Total:</label><input data-value="50" type="text" readonly class="total" value="50"/></td>
<td><label>Qty:</label><input type="text" class="qty" value="5" /></td>
<td><label>Total1:</label><input data-value="50" type="text" readonly class="total1"/></td>
<td><label>Price/Unit:</label><input type="text" readonly class="price_unit"/></td>
</tr></table>
</div>
</body>
</html>
Your .qty input has a value and you are trying to get its data-value
Try this
$("select").on('change', function () {
var dept_number = $(this).val();
var price = $(this).find(':selected').data('price');
$(this).closest('table').find('.deptip').val(dept_number);
$(this).closest('table').find('.priceip').val(price);
$(this).closest('table').find('.total1').val(price * $(this).closest('table').find('.total').data('value'));
$(this).closest('table').find('.price_unit').val($(this).closest('table').find('.total1').data('value') / $(this).closest('table').find('.qty').val());
});
https://jsfiddle.net/zu6uvzxv/2/
You need to convert string var to float or int using parseInt or parseFloat
$(this).closest('table').find('.price_unit').val(parseInt($(this).closest('table').find('.total1').attr('value')) / parseInt($(this).closest('table').find('.qty').attr('value')));
Related
I have a select box with a few dropdown options. Under each option there will be a checklist and total (each checklist item has a value). I need to accomplish this using pure javascript.
My problem is I don't know how to make each checklist specific to its dropdown item, and to reset the checkbox values after a user clicks a new dropdown option. I've tried calling the totalIt function in the display function but I can't get it to work.
Fiddle
My HTML is:
<div>
<select id="store">
<option value="A">Location A</option>
<option value="B">Location B</option>
<option value="C">Location C</option>
</select>
</div>
<div class="box A">
Location A<br>
<input name="product" value="20" type="checkbox" onclick="totalIt()" /> 20%<br>
<input name="product" value="15" type="checkbox" onclick="totalIt()" /> 15%<br>
Total:
<input value="0" readonly="readonly" type="text" name="total" />
</div>
<div class="box B">
Location B
<br>
<input name="product" value="20" type="checkbox" onclick="totalIt()" /> 20%<br>
<input name="product" value="15" type="checkbox" onclick="totalIt()" /> 15%<br>
Total:
<input value="0" readonly="readonly" type="text" name="total" />
</div>
<div class="box C">
Location C
<br>
<input name="product" value="20" type="checkbox" onclick="totalIt()" /> 20%<br>
<input name="product" value="15" type="checkbox" onclick="totalIt()" /> 15%<br>
Total:
<input value="0" readonly="readonly" type="text" name="total" />
</div>
CSS:
.hide {
display: none;
}
JS:
document.querySelector("select#store").addEventListener("change", () => {
display(event.target.value);
});
const boxs = document.querySelectorAll("div.box");
// Select box show/hide div
function display(value) {
for (const box of boxs) {
if (box.classList.contains(value)) {
box.classList.remove("hide");
} else {
box.classList.add("hide");
}
}
}
display("A");
// Total the values of the checkboxes
function totalIt() {
var input = document.getElementsByName("product");
var total = 0;
for (var i = 0; i < input.length; i++) {
if (input[i].checked) {
total += parseFloat(input[i].value);
}
}
document.getElementsByName("total")[0].value = total + "%";
}
Try to use the selected box children property. So that only those elements under the box would be updated. You are almost there I just had to tweak the code just a little.
HTML:
<div>
<select id="store">
<option value="A">Location A</option>
<option value="B">Location B</option>
<option value="C">Location C</option>
</select>
</div>
<div class="box A">
Location A <br>
Select your items:
<br>
<input name="proPercent1" value="20" type="checkbox" onclick="totalIt()"/> 20%<br>
<input name="proPercent2" value="15" type="checkbox" onclick="totalIt()"/> 15%<br>
Total:<br>
<input value="0" readonly="readonly" type="text" name="total" />
</div>
<div class="box B">
Location B <br>
Select your items:
<br>
<input name="proPercent1" value="20" type="checkbox" onclick="totalIt()"/> 20%<br>
<input name="proPercent2" value="15" type="checkbox" onclick="totalIt()"/> 15%<br>
Total:<br>
<input value="0" readonly="readonly" type="text" name="total" />
</div>
<div class="box C">
Location C <br>
Select your items:
<br>
<input name="proPercent1" value="20" type="checkbox" onclick="totalIt()" name="percentage1"/> 20%<br>
<input name="proPercent2" value="15" type="checkbox" onclick="totalIt()"/> 15%<br>
Total:<br>
<input value="0" readonly="readonly" type="text" name="total" />
</div>
JS:
document.querySelector("select#store").addEventListener("change", () => {
display(event.target.value);
});
const boxs = document.querySelectorAll("div.box");
let selectedBox = "";
function display(value) {
for (const box of boxs) {
if (box.classList.contains(value)) {
box.classList.remove("hide");
selectedBox = box;
} else {
box.classList.add("hide");
}
}
}
display("A");
// Total the values of the checkboxes
function totalIt() {
let total = 0;
if(selectedBox.children.proPercent1.checked) total = total + parseInt(selectedBox.children.proPercent1.value)
if(selectedBox.children.proPercent2.checked) total = total + parseInt(selectedBox.children.proPercent2.value)
selectedBox.children.total.value = `${total} %`;
}
Hopefully this helps
Hi,
I get solution to your problem...
document.querySelector("select#store").addEventListener("change", () => {
display(event.target.value);
});
const boxs = document.querySelectorAll("div.box");
// Select box show/hide div
function display(value) {
for (const box of boxs) {
if (box.classList.contains(value)) {
box.classList.remove("hide");
} else {
box.classList.add("hide");
}
}
}
display("A");
// Total the values of the checkboxes
function totalIt(Group) {
let input = document.querySelectorAll(`.${Group} [name=product]`),
total = 0,
totalInput = document.querySelector(`.${Group} [name=total]`)
input.forEach(input => {
if(input.checked) total += parseFloat(input.value);
totalInput.value = total + "%"
})
}
.hide {
display: none;
}
.box {
margin-top:30px;
}
<div>
<select id="store">
<option value="A">Location A</option>
<option value="B">Location B</option>
<option value="C">Location C</option>
</select>
</div>
<div class="box A">
Location A<br>
<input name="product" value="20" type="checkbox" onclick="totalIt('A')" /> 20%<br>
<input name="product" value="15" type="checkbox" onclick="totalIt('A')" /> 15%<br>
Total:
<input value="0" readonly="readonly" type="text" name="total" />
</div>
<div class="box B">
Location B
<br>
<input name="product" value="20" type="checkbox" onclick="totalIt('B')" /> 20%<br>
<input name="product" value="15" type="checkbox" onclick="totalIt('B')" /> 15%<br>
Total:
<input value="0" readonly="readonly" type="text" name="total" />
</div>
<div class="box C">
Location C
<br>
<input name="product" value="20" type="checkbox" onclick="totalIt('C')" /> 20%<br>
<input name="product" value="15" type="checkbox" onclick="totalIt('C')" /> 15%<br>
Total:
<input value="0" readonly="readonly" type="text" name="total" />
</div>
I Convert for loop to forEach array loop
I Change the selector from getElementsByNames to querySelector and querySelectorAll
I Add argument to the function represent the Group
I Noticed that you add class for each Group represent Name
I Use this to make input selector and totalInput selector dedicated for each group... Like document.querySelectorAll(.a [name=product])
Finally I call function and type name group in html
To uncheck a checkbox you set the element.checked value to false, (more here Check/Uncheck checkbox with JavaScript)
const allCheckboxes = document.querySelectorAll('input[type="checkbox"]');
function display (value) {
allCheckboxes.forEach(element => element.checked = false);
// your code
...
}
I Have two Select Box with the same class.I am trying to add a class on the change of select option.
HTML:
<select class="selectProduct" name="product_id[]">
<option value="T-shirt">T-Shirt</option>
</select>
<input type="text" name="sku[]" placeholder="Code" id ="sku" class="code" />
<input type="text" name="qty[]" placeholder="Qty" id ="qty" class="qty" />
<select class="selectProduct" name="product_id[]" style="width:400px;">
<option value="shirt">Shirt</option>
</select>
<input type="text" name="sku[]" placeholder="Code" id ="sku" class="code" />
<input type="text" name="qty[]" placeholder="Qty" id ="qty" class="qty" />
jQuery:
$(document).on('change', '.selectProduct', function(e) {
var idSize = $(this).val();
$(this).find(".code").addClass(idSize);
});
Your select and input is in same hierarchy so use next to get input and add class .
find search inside the element you give so why your code is fail.
$(document).on('change', '.selectProduct', function(e) {
var idSize = $(this).val();
$(this).next(".code").addClass(idSize);
$(this).next().next(".qty").addClass(idSize);
});
.shirt {
outline: none !important;
border: 1px solid red;
}
.T-shirt {
outline: none !important;
border: 1px solid blue;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select class="selectProduct" name="product_id[]">
<option value="T-shirt">T-Shirt</option>
<option value="shirt">shirt</option>
</select>
<input type="text" name="sku[]" placeholder="Code" id="sku" class="code" />
<input type="text" name="qty[]" placeholder="Qty" id="qty" class="qty" />
<select class="selectProduct" name="product_id[]" style="width:400px;">
<option value="T-shirt">T-Shirt</option>
<option value="shirt">Shirt</option>
</select>
<input type="text" name="sku[]" placeholder="Code" id="sku" class="code" />
<input type="text" name="qty[]" placeholder="Qty" id="qty" class="qty" />
The user can only change the value if the select box has more than one option, and it's easier to find the correct .code input to modify if we group the related inputs together.
Here's a revised version of your code that does as you suggest:
const container = document.querySelector('#container-div');
container.addEventListener('change', addValAsClass);
function addValAsClass(event){
const codeBox = event.target.closest(".input-group").querySelector(".code");
codeBox.classList.add(event.target.value);
console.log(`classList: ${codeBox.getAttribute('class')}`);
}
div + div { margin-top: 10px; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="container-div">
<div class="input-group">
<select class="selectProduct">
<option value="opt1">Opt 1</option>
<option value="opt2">Opt 2</option>
</select>
<input placeholder="Code" class="code" />
<input placeholder="Qty" class="qty" />
</div>
<div class="input-group">
<select class="selectProduct">
<option value="optA">Opt A</option>
<option value="optB">Opt B</option>
</select>
<input placeholder="Code" class="code" />
<input placeholder="Qty" class="qty" />
</div>
</div>
i suggest wrapping the select + input into another div, to make finding easier.
your code might not work, because you have elements with non-unique id (sku and qty).
<div> <!-- wrapper start -->
<select class="selectProduct" name="product_id[]">
<option value="T-shirt">T-Shirt</option>
</select>
<input type="text" name="sku[]" placeholder="Code" id="code" class="code" />
<input type="text" name="qty[]" placeholder="Qty" id="qty" class="qty" />
<div> <!-- wrapper end -->
<div> <!-- wrapper start -->
<select class="selectProduct" name="product_id[]">
<option value="T-shirt">T-Shirt</option>
</select>
<input type="text" name="sku[]" placeholder="Code" id="code" class="code" />
<input type="text" name="qty[]" placeholder="Qty" id="qty" class="qty" />
<div> <!-- wrapper end -->
now you can find the next input by class in its parent container:
$(document).on('change', '.selectProduct', function(e) {
var idSize = $(this).val();
$(this).parent().find(".code").addClass(idSize); // <-- parent
})
Here is a snip of my form i am using. I am using javascript to set the value of the dollars and cents to the 2 and 00 but it does not work. Can anyone correct this? Thank you
<select class="element select medium" id="element_8" name="element_8" onChange="update_txt()">
<option value="" selected="selected"></option>
<option value="First option" >First option</option>
<option value="Second option" >Second option</option>
<option value="Third option" >Third option</option>
</select>
<input id="subtotal" name="subtotal" class="element text currency" size="10" value="" type="text" /> .
<label for="subtotal">Dollars</label>
<input id="subtotalcents" name="subtotalcents" class="element text" size="2" maxlength="2" value="" type="text" />
<label for="subtotalcents">Cents</label>
<script>function update_txt(){
price = document.getElementById('element_8').value;
document.getElementById('element_7').value = price;
document.getElementById('element_7').focus();
document.getElementbyId('subtotal').value ='2';
document.getElementbyId('subtotalcents').value ='00';
}
</script>
It is document.getElementById('subtotal').value ='2';it is capital "B"
function update_txt(){
price = document.getElementById('element_8').value;
document.getElementById('element_7').value = price;
document.getElementById('element_7').focus();
document.getElementById('subtotal').value ='2';
document.getElementById('subtotalcents').value ='00';
}
P.S: There is no element_7 in the code u provided, but hoping it is present in the actual code ur using.
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>function update_txt(){
debugger
price = document.getElementById('element_8').value;
document.getElementById('element_7').value = price;
document.getElementById('element_7').focus();
document.getElementById('subtotal').value ='2';
document.getElementById('subtotalcents').value ='00';
}
</script>
</head>
<body>
<select class="element select medium" id="element_8" name="element_8" onChange="update_txt()">
<option value="" selected="selected"></option>
<option value="First option" >First option</option>
<option value="Second option" >Second option</option>
<option value="Third option" >Third option</option>
</select>
<input id="element_7" name="element_7" class="element text currency" size="10" value="" type="text" /> .
<input id="subtotal" name="subtotal" class="element text currency" size="10" value="" type="text" /> .
<label for="subtotal">Dollars</label>
<input id="subtotalcents" name="subtotalcents" class="element text" size="2" maxlength="2" value="" type="text" />
<label for="subtotalcents">Cents</label>
</body>
</html>
I have a small set of rows for a program i'm creating. Im trying to create a set of fields that a user can fill in, some time we need more rows than one so i created a javascript dynamically add row set.
I'm trying to style the fields for a fluid layout (between a pc and tablet). Im having difficulty getting them to work with both layout sizes. Secondly if i try to add headings (of some description) to the rows i can never get them to line up at all.
Any Suggestions? I have a link to some of my code here --> https://jsfiddle.net/c92qvuxe/
<div id="materials">
<!-- Start of Table -->
<form name="Add_Units" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<fieldset>
<div id="row">
<input name="Page_0" type="text" value=""/>
<input name="Weight_0" type="text" value=""/>
<select name="Finish_0">
<option value="Gloss">Gloss</option>
<option value="Silk">Silk</option>
<option value="Matt">Matt</option>
<option value="Offset">Offset</option>
<option value="NCR">NCR</option>
</select>
<input name="PaperName_0" type="text" value=""/>
<input name="Grain_0" type="text" value=""/>
<select name="Size_0">
<option value="SRA3">SRA3</option>
<option value="SRA2">SRA2</option>
<option value="SRA1">SRA1</option>
<option value="B2">B2</option>
<option value="B1">B1<option>
</select>
<input name="Supplier_0" type="text" value=""/>
<input name="Stock_0" type="checkbox" value="1"/>
<input name="SheetQty_0" type="text" value=""/>
</div>
<div id="newrow" style="display: none;">
<input name="Page_" type="text" value="" size="5" maxlength="55" />
<input name="Weight_" type="text" value="" size="10" maxlength="55" />
<select name="Finish_">
<option value="Gloss">Gloss</option>
<option value="Silk">Silk</option>
<option value="Matt">Matt</option>
<option value="Offset">Offset</option>
<option value="NCR">NCR</option>
</select>
<input name="PaperName_" type="text" value="" size="10" maxlength="55" />
<input name="Grain_" type="text" value="" size="10" maxlength="55" />
<select name="Size_">
<option value="SRA3">SRA3</option>
<option value="SRA2">SRA2</option>
<option value="SRA1">SRA1</option>
<option value="B2">B2</option>
<option value="B1">B1<option>
<input name="Supplier_" type="text" value="" size="10" maxlength="55" />
<input name="Stock_" type="checkbox" value="1" size="10" />
<input name="SheetQty_" type="text" value="" size="10" maxlength="55" />
</div>
<p>
<input type="button" id="add_row()" onclick="add_row()" value="Add Row" />
<!--<input type="submit" name="Add_Unit" value="Save Units" />-->
</p>
<p> </p>
</fieldset>
</form>
<br />
I need these two fields to be multiplied together based on selected form options.
Okay so it works without all the extra fields but once i added the rest of the form the calculation stopped working. :(
<form action="mailer.php" data-validate="parsley" method="post" >
<p><strong>Full Name<span class="red">*</span></strong></p>
<input name="cf_name" data-required="true" class="send" type="text" />
<p><strong>Email Address<span class="red">*</span></strong></p>
<input name="cf_email" data-required="true" data-type="email" class="send" type="text" />
<p><strong>Cellphone No.<span class="red">*</span></strong></p>
<input name="cf_cell" data-required="true" class="send" type="text" />
<p><strong>Instrument Type<span class="red">*</span></strong></p>
<select name="cf_instrument" size="1" class="option" >
<option value="Piano">Piano</option>
<option value="Vocals">Vocals</option>
<option value="Guitar">Guitar</option>
<option value="Bass">Bass</option>
<option value="Flute">Flute</option></select>
<p><strong>Lesson Type<span class="red">*</span></strong></p>
<select name="cf_package_type" id="cf_package_type" size="1" class="option">
<option value="100">Beginner Lesson - R100</option>
<option value="130">Advanced Lesson - R130</option>
<option value="160">Professional Lesson - R160</option></select>
<p><strong>No. of Lessons<span class="red">*</span></strong></p>
<select id="number-of-lessons" name="cf_number" size="1" class="option" onchange='test()'>
<option name="1" value="1" selected="selected">1</option>
<option name="2" value="2">2</option>
<option name="3" value="3">3</option>
<option name="4" value="4">4</option></select>
<script src="js/datepair.js"></script>
<p><strong>Lesson Date & Time<span class="red">*</span></strong></p>
<p class="datepair" data-language="javascript">
<input type="text" name="cf_booking_date" class="date start" data-required="true" />
<input type="text" name="cf_start_time" class="time start" data-required="true" /> to
<input type="text" name="cf_end_time" class="time end" data-required="true" /></p>
<script src="js/datepair.js"></script>
<p id="lesson-2" class="datepair" data-language="javascript">
<input type="text" name="cf_booking_date" class="date start" data-required="true" />
<input type="text" name="cf_start_time" class="time start" data-required="true" /> to
<input type="text" name="cf_end_time" class="time end" data-required="true" /></p>
<script src="js/datepair.js"></script>
<p id="lesson-3" class="datepair" data-language="javascript">
<input type="text" name="cf_booking_date" class="date start" data-required="true" />
<input type="text" name="cf_start_time" class="time start" data-required="true" /> to
<input type="text" name="cf_end_time" class="time end" data-required="true" /></p>
<script src="js/datepair.js"></script>
<p id="lesson-4" class="datepair" data-language="javascript">
<input type="text" name="cf_booking_date" class="date start" data-required="true" />
<input type="text" name="cf_start_time" class="time start" data-required="true" /> to
<input type="text" name="cf_end_time" class="time end" data-required="true" /></p>
<!-- HIDDEN FIELD - HONEYPOT ANTI_SPAM -->
<input id="website" class="using" name="website" type="text" />
<!-- END -->
<input name="Submit" class="submit" value="Book Now" type="submit" /></form>
<input type="text" value="100" disabled="disabled" id="result">
Corrected JS used:
<script type="text/javascript">
$("select").change(function(){
var val1 = + ($("#cf_package_type").val());
var val2 = + ($("#number-of-lessons").val());
$("#result").val(val1*val2);
});
</script>
I know i'm probably very off-track but if someone could please help me with this it would be a life-saver!
Here's the JS fiddle to help you - http://jsfiddle.net/GuBPL/10/
Thank you.
Try with following code:
<p><strong>Lesson Type<span class="red">*</span></strong></p>
<select id="cf_package_type" name="cf_package_type" size="1" class="option">
<option value="100">Beginner Lesson - R100</option>
<option value="130">Advanced Lesson - R130</option>
<option value="160">Professional Lesson - R160</option>
</select>
<p><strong>No. of Lessons<span class="red">*</span></strong></p>
<select id="number-of-lessons" name="cf_number" size="1" class="option">
<option value="1" selected="selected">1</option>
<option name="2" value="2">2</option>
<option name="3" value="3">3</option>
<option name="4" value="4">4</option>
</select>
<input type="text" disabled="disabled" id="result">
And JS:
$(document).ready(function(){
$("#number-of-lessons").change(function(){
var val1 = parseInt($("#cf_package_type").val());
var val2 = parseInt($(this).val());
$("#result").val(val1*val2);
});
});
What's changed ?
First select got id="cf_package_type" attribute, which is used to get its value with:
$("#cf_package_type").val()
Removed onchange='test()' because we do it with jQuery:
$("#number-of-lessons").change()
Get value of second select with:
$(this).val()
because we work on it already.
parseInt used just to be sure, we use integers, not strings.
Edit:
To calculate result on page load, use:
$(document).ready(function(){
var calculate = function(){
var val1 = parseInt($("#cf_package_type").val());
var val2 = parseInt($('#number-of-lessons').val());
$("#result").val(val1*val2);
};
$("#number-of-lessons").change(calculate);
calculate();
});
You use $('.select') while the elements have class name option,
You should use change event instead of keyup
you use $('.cf_package_type') while it's a name, not class attribute
http://jsfiddle.net/GuBPL/4/
$(document).ready(function(){
$(".option").change(function(){
var val1 = +$("[name=cf_package_type]").val();
var val2 = +$("[name=cf_number]").val();
$("#result").val(val1*val2);
});
});