I'm working on developing a web application that connects to a database for a class that I'm taking. The particular page that I'm working on displays a type of internet service available for a zip code. The services are displayed as radio buttons, and I want the price to show/change based on the radio button that is already checked (when the page loads) or is manually checked. Below is the script to change the text/innerHTML of #servicePriceString.
For some reason, not only does the price not show up, but I've tested the "showPrice()" function with something simple like an alert(), but that doesn't seem to work either. Any help/suggestions would be greatly appreciated. Side note, I'm really new at this, so take it easy on poorly-formatted/bad code ;)
EDIT: I know that the input is outside the form and have since corrected that. It's still not working. Also, I know that I'm not using "var checkedvalue". I was using that previously and haven't removed it yet.
<script type="text/javascript">
function showPrice(i) {
var myRadio = document.getElementById("availableService");
var checkedValue = myRadio.filter(':checked').valueOf();
price = rs[0][i].monthly_price;
document.getElementById("servicePriceString").innerHTML = price;
}
</script>
<form action="/placeorder">
<% for ( var i=0; i < rs[0].length; i++) { %>
<div id="serviceAvailableArea">
<input onclick="showPrice(<%= i %>)" type="radio" id="availableService" name="availableService"
value="<%= i %>">
<%= rs[0][i].service_name %> at <%= rs[0][i].speed %>Mbps
</div>
<br/>
<% }%>
</form>
<input type="submit" value="Place Order" id="placeOrderButton">
<div id="servicePrice">
<p id="servicePriceString">test</p>