Razzy
06-25-2012, 09:05 PM
hello people,
i am creating a website for a meatshop and i am stuck on the order form page which requires a fair bit of javascript which i am quite new to, on the order form i have 4 dropdown menus, with all 4 having similar values:
<script type="text/javascript">
function addDrops() {
var sausageOne = document.getElementById( 'sausage1');
var sausageTwo = document.getElementById( 'sausage2');
document.getElementById( 'output').value = parseFloat(sausage1.options[ sausage1.options.selectedIndex ].value
) + parseFloat(sausage2.options[ sausage2.options.selectedIndex ].value
);
)
</script>
<body>
<SELECT name="sausage1" id="sausage1" onchange="addDrops()" >
<OPTION VALUE="" >
<OPTION value="5.99">KQF bolly Chicken Sausages
<OPTION value="4.00">KQF bolly Lamb Sausages
<OPTION value="3.99">KQF Jumbo Lamb Sausages
</SELECT>
<SELECT name="sausage2" id="sausage2" onchange="addDrops()">
<OPTION VALUE="" >
<OPTION value="5.99">KQF bolly Chicken Sausages
<OPTION value="4.00">KQF bolly Lamb Sausages
<OPTION value="5.99">KQF Jumbo Lamb Sausages
</SELECT>
<SELECT name="sausage2" id="sausage3" onchange="addDrops()">
<OPTION VALUE="" >
<OPTION value="5.99">KQF bolly Chicken Sausages
<OPTION value="4.00">KQF bolly Lamb Sausages
<OPTION value="5.99">KQF Jumbo Lamb Sausages
</SELECT>
<SELECT name="sausage2" id="sausage4" onchange="addDrops()">
<OPTION VALUE="" >
<OPTION value="5.99">KQF bolly Chicken Sausages
<OPTION value="4.00">KQF bolly Lamb Sausages
<OPTION value="5.99">KQF Jumbo Lamb Sausages
</SELECT>
<input type="text" id='output'/>
</body>
when i select an option from the first dropdown menu the output should automatically appear on the textbox, and if i select an option from another dropdown menu then the value of the other dropdown menu should add to the value of the first dropdown menu etc. ive been trying to use the javascript above but it does not work :(
would really appreciate it if someone could help
thank you
i am creating a website for a meatshop and i am stuck on the order form page which requires a fair bit of javascript which i am quite new to, on the order form i have 4 dropdown menus, with all 4 having similar values:
<script type="text/javascript">
function addDrops() {
var sausageOne = document.getElementById( 'sausage1');
var sausageTwo = document.getElementById( 'sausage2');
document.getElementById( 'output').value = parseFloat(sausage1.options[ sausage1.options.selectedIndex ].value
) + parseFloat(sausage2.options[ sausage2.options.selectedIndex ].value
);
)
</script>
<body>
<SELECT name="sausage1" id="sausage1" onchange="addDrops()" >
<OPTION VALUE="" >
<OPTION value="5.99">KQF bolly Chicken Sausages
<OPTION value="4.00">KQF bolly Lamb Sausages
<OPTION value="3.99">KQF Jumbo Lamb Sausages
</SELECT>
<SELECT name="sausage2" id="sausage2" onchange="addDrops()">
<OPTION VALUE="" >
<OPTION value="5.99">KQF bolly Chicken Sausages
<OPTION value="4.00">KQF bolly Lamb Sausages
<OPTION value="5.99">KQF Jumbo Lamb Sausages
</SELECT>
<SELECT name="sausage2" id="sausage3" onchange="addDrops()">
<OPTION VALUE="" >
<OPTION value="5.99">KQF bolly Chicken Sausages
<OPTION value="4.00">KQF bolly Lamb Sausages
<OPTION value="5.99">KQF Jumbo Lamb Sausages
</SELECT>
<SELECT name="sausage2" id="sausage4" onchange="addDrops()">
<OPTION VALUE="" >
<OPTION value="5.99">KQF bolly Chicken Sausages
<OPTION value="4.00">KQF bolly Lamb Sausages
<OPTION value="5.99">KQF Jumbo Lamb Sausages
</SELECT>
<input type="text" id='output'/>
</body>
when i select an option from the first dropdown menu the output should automatically appear on the textbox, and if i select an option from another dropdown menu then the value of the other dropdown menu should add to the value of the first dropdown menu etc. ive been trying to use the javascript above but it does not work :(
would really appreciate it if someone could help
thank you