Hi,
What I am in the process of putting together is an online quote calculator that allows a consultant to go see a holtelier and they work out a contract value.
The idea in the link below, its in a very basic format at the moment, is that the consultant has this option in amongst the rest of the form, which when he clicks a button a form appears, and then if they have anymore hotels, they can click the button again and the same dropdowns appeara nd away tehy go again, each with a total, but every forms total will add up to a total total.
This is the link - http://www.accend4web.co.uk/OCalculator/design.php
function active_tiptip() {
var selects = [
{
"1": "test 1",
"2": "test 2"
}, {
"1": "test 1",
"2": "test 2"
}, {
"1": "test 1",
"2": "test 2"
}, {
"1": "test 1",
"2": "test 2"
}, {
"1": "test 1",
"2": "test 2"
}, {
"1": "test 1",
"2": "test 2"
}, {
"1": "test 1",
"2": "test 2"
}, {
"1": "test 1",
"2": "test 2"
}, {
"1": "test 1",
"2": "test 2"
}];
$('#test')
.append('<form id="form1" name="form1"></form>');
$.each(selects, function (i, v) {
var select=$("<select id='select"+i+"'></select>").appendTo("#form1")
console.log(i, v)
$.each(v,function(value,key){
$("<option></option>",{value:value,text:key}).appendTo(select)
})
})
$("<div class='sum'></div>").appendTo("#form1")
$("#form1").find("select").change(function(){
var total=0
$(this).prevUntil(".sum").add($(this).nextUntil(".sum")).each(function(){
console.log(this)
total+= +$(this).val();
})
$(this).nextAll('.sum:first').text('£' + total);
})
}
$('#test')
.append("<div class='sumTotal'>Total Total in here</div>");
Im struggling with two things, the first being how do I get the id=sum to show the total values of each form on load, rather than having to wait until a change occurs, and then carrying on as is once a change has been selected and the sum changes. Its that load the value before having to wait for a change