## Need help with radio inputs and javascript for school project

So we have to let the user input the weight of an item between 0 and 400. and depending on the weight the price per pound is different.

0 - 150 lbs = \$20
151 - 300 lbs = \$15
301 - 400 = \$10

On top of this, there are 3 radio buttons, 50% discount, 25% discount, and No Discount. I'm having trouble detecting which radio button the user has selecting and obtaining the value that i have put for it in the HTML. If somebody could guide me in the right direction, it would be greatly appreciated. Here is my JavaScript...

Code:
```<script type="text/javascript">

function shippingTotal() {

var itemweight = parseInt( document.getElementById("itemweight").value );
var disc50 = document.getElementById("disc50").value;
var disc25 = document.getElementById("disc25").value;
var disc00 = document.getElementById("disc00").value;
var subtotal;
var weighttotal;
var discount;
var grandtotal;

if ( itemweight < 0 || itemweight > 400 ) {

msg = "<div id='alertmsg'>That weight is not accepted. Please try again.</div>";

} // <- ends if below zero or over four hundred

else { // <- first radio button

if  ( disc50.checked = true ) {

if ( itemweight > 0 && itemweight <= 150 ) {

weighttotal = itemweight * 20;
subtotal = itemweight * disc50 * 20;
discount = ( disc50 / 100 ) * 20;
grandtotal = weighttotal - discount;

msg = "<div id='resmessage'>Total weight is " + itemweight + " pounds</div>";
msg = msg + "<div id='resmessage'>Weight cost is \$" + weighttotal.toFixed(2);  + "</div>";
msg = msg + "<div id='resmessage'>Discount rate is " + disc50 + "%</div>";
msg = msg + "<div id='resmessage'>Discount amount is \$" + discount.toFixed(2);  + "</div>";
msg = msg + "<div id='resmessage'>Total cost is \$" + grandtotal.toFixed(2);  + "</div>";

} // <- ends itemweight is between zero and one fifty

else {

if ( itemweight > 150 && itemweight <= 300 ) {

weighttotal = itemweight * 15;
subtotal = itemweight * disc50 * 15;
discount = ( disc50 / 100 ) * 15;
grandtotal = weighttotal - discount;

msg = "<div id='resmessage'>Total weight is " + itemweight + " pounds</div>";
msg = msg + "<div id='resmessage'>Weight cost is \$" + weighttotal.toFixed(2);  + "</div>";
msg = msg + "<div id='resmessage'>Discount rate is " + disc50 + "%</div>";
msg = msg + "<div id='resmessage'>Discount amount is \$" + discount.toFixed(2);  + "</div>";
msg = msg + "<div id='resmessage'>Total cost is \$" + grandtotal.toFixed(2);  + "</div>";

} // <- ends itemweight is between one fifty and three hundred

else {

weighttotal = itemweight * 10;
subtotal = itemweight * disc50 * 10;
discount = ( disc50 / 100 ) * 10;
grandtotal = weighttotal - discount;

msg = "<div id='resmessage'>Total weight is " + itemweight + " pounds</div>";
msg = msg + "<div id='resmessage'>Weight cost is \$" + weighttotal.toFixed(2);  + "</div>";
msg = msg + "<div id='resmessage'>Discount rate is " + disc50 + "%</div>";
msg = msg + "<div id='resmessage'>Discount amount is \$" + discount.toFixed(2);  + "</div>";
msg = msg + "<div id='resmessage'>Total cost is \$" + grandtotal.toFixed(2);  + "</div>";

} // <- ends itemweight between three hundred and four hundred

} // <- ends else about not being between zero and one fifty

} // <- ends else  between zero and four hundred

else { // <- second radio button

if  ( disc25.checked = true ) {

if ( itemweight > 0 && itemweight <= 150 ) {

weighttotal = itemweight * 20;
subtotal = itemweight * disc25 * 20;
discount = ( disc25 / 100 ) * 20;
grandtotal = weighttotal - discount;

msg = "<div id='resmessage'>Total weight is " + itemweight + " pounds</div>";
msg = msg + "<div id='resmessage'>Weight cost is \$" + weighttotal.toFixed(2);  + "</div>";
msg = msg + "<div id='resmessage'>Discount rate is " + disc25 + "%</div>";
msg = msg + "<div id='resmessage'>Discount amount is \$" + discount.toFixed(2);  + "</div>";
msg = msg + "<div id='resmessage'>Total cost is \$" + grandtotal.toFixed(2);  + "</div>";

} // <- ends itemweight is between zero and one fifty

else {

if ( itemweight > 150 && itemweight <= 300 ) {

weighttotal = itemweight * 15;
subtotal = itemweight * disc25 * 15;
discount = ( disc25 / 100 ) * 15;
grandtotal = weighttotal - discount;

msg = "<div id='resmessage'>Total weight is " + itemweight + " pounds</div>";
msg = msg + "<div id='resmessage'>Weight cost is \$" + weighttotal.toFixed(2);  + "</div>";
msg = msg + "<div id='resmessage'>Discount rate is " + disc25 + "%</div>";
msg = msg + "<div id='resmessage'>Discount amount is \$" + discount.toFixed(2);  + "</div>";
msg = msg + "<div id='resmessage'>Total cost is \$" + grandtotal.toFixed(2);  + "</div>";

} // <- ends itemweight is between one fifty and three hundred

else {

weighttotal = itemweight * 10;
subtotal = itemweight * disc25 * 10;
discount = ( disc25 / 100 ) * 10;
grandtotal = weighttotal - discount;

msg = "<div id='resmessage'>Total weight is " + itemweight + " pounds</div>";
msg = msg + "<div id='resmessage'>Weight cost is \$" + weighttotal.toFixed(2);  + "</div>";
msg = msg + "<div id='resmessage'>Discount rate is " + disc25 + "%</div>";
msg = msg + "<div id='resmessage'>Discount amount is \$" + discount.toFixed(2);  + "</div>";
msg = msg + "<div id='resmessage'>Total cost is \$" + grandtotal.toFixed(2);  + "</div>";

} // <- ends itemweight between three hundred and four hundred

} // <- ends else about not being between zero and one fifty

} // <- ends else  between zero and four hundred

} // <- ends second radio button else

else { // <- third radio button

if  ( disc00.checked = true ) {

if ( itemweight > 0 && itemweight <= 150 ) {

weighttotal = itemweight * 20;
subtotal = itemweight * 20;
discount = 0;
grandtotal = weighttotal - discount;

msg = "<div id='resmessage'>Total weight is " + itemweight + " pounds</div>";
msg = msg + "<div id='resmessage'>Weight cost is \$" + weighttotal.toFixed(2);  + "</div>";
msg = msg + "<div id='resmessage'>Discount rate is " + disc00 + "%</div>";
msg = msg + "<div id='resmessage'>Discount amount is \$" + discount.toFixed(2);  + "</div>";
msg = msg + "<div id='resmessage'>Total cost is \$" + grandtotal.toFixed(2);  + "</div>";

} // <- ends itemweight is between zero and one fifty

else {

if ( itemweight > 150 && itemweight <= 300 ) {

weighttotal = itemweight * 15;
subtotal = itemweight * 15;
discount = 0;
grandtotal = weighttotal - discount;

msg = "<div id='resmessage'>Total weight is " + itemweight + " pounds</div>";
msg = msg + "<div id='resmessage'>Weight cost is \$" + weighttotal.toFixed(2);  + "</div>";
msg = msg + "<div id='resmessage'>Discount rate is " + disc00 + "%</div>";
msg = msg + "<div id='resmessage'>Discount amount is \$" + discount.toFixed(2);  + "</div>";
msg = msg + "<div id='resmessage'>Total cost is \$" + grandtotal.toFixed(2);  + "</div>";

} // <- ends itemweight is between one fifty and three hundred

else {

weighttotal = itemweight * 10;
subtotal = itemweight * 10;
discount = 0;
grandtotal = weighttotal - discount;

msg = "<div id='resmessage'>Total weight is " + itemweight + " pounds</div>";
msg = msg + "<div id='resmessage'>Weight cost is \$" + weighttotal.toFixed(2);  + "</div>";
msg = msg + "<div id='resmessage'>Discount rate is " + disc00 + "%</div>";
msg = msg + "<div id='resmessage'>Discount amount is \$" + discount.toFixed(2);  + "</div>";
msg = msg + "<div id='resmessage'>Total cost is \$" + grandtotal.toFixed(2);  + "</div>";

} // <- ends itemweight between three hundred and four hundred

} // <- ends else about not being between zero and one fifty

} // <- ends else  between zero and four hundred

} // <- ends third radio button else

}// <- ends else about the itemweight being between zero and four hundrred

document.getElementById("results").innerHTML = msg;

} // <-ends function shippingTotal
</script>```