View Single Post
Old 07-27-2010, 01:24 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,036
Thanks: 197
Thanked 2,411 Times in 2,389 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Sounds like homework! Or do you think that this forum is a free coding service?

Show us your effort and then I am sure that someone will correct/improve it for you. If the user may select more than one extra then you need to use checkboxes, not radios.

This will give you a start:-

Code:
<form name= "myform">
<input type = "radio" name = "rad1" value = "20Package1">Package 1
<input type = "radio" name = "rad1" value = "50Package2">Package 2
<input type = "radio" name = "rad1" value = "75Package3">Package 3
<br><br>
<input type = "button" value = "Which Package Selected?" onclick = "chkrads()">
</form>

<script type = "text/javascript">

function chkrads() {
var chosen = "None";
var len = document.myform.rad1.length;
for (i = 0; i <len; i++) {
if (document.myform.rad1[i].checked) {
chosen = document.myform.rad1[i].value;
}
}
if (chosen == "None") {
alert("No Package Chosen");
}
else {
var price = parseInt(chosen);
var pl = price.toString().length;
chosen = chosen.substring(pl);
alert("You selected  " +  chosen + " costing £" + price);
}
}

</script>

BTW, the time to say "thanks" is afterwards, not beforehand which gives the - doubtless unintended - impression that you take other people's voluntary unpaid assistance and expertise for granted. Or as British politician Neil Kinnock put it, "Don't belch before you have had the meal." Prefer to use "please" beforehand and if you find a response helpful then you can use the "Thank User For This Post" button.


The ball is unpredicatble, but not all the time. - Football Commentator, Radio 5 Live
Philip M is online now   Reply With Quote