wilcor14
asked on
Get value of selected radio input button in Masterpage
using javascript, I need to find out which radio button was selected from the group name "rPaymentMethod". I am using masterpages. Thanks.
<input id="rCreditCard" runat="server" type="radio" name="rPaymentMethod" value="CreditCard" />CreditCard
<input id="rPayPal" runat="server" type="radio" name="rPaymentMethod" value="PayPal" />PayPal
<input id="rCreditCard" runat="server" type="radio" name="rPaymentMethod" value="CreditCard" />CreditCard
<input id="rPayPal" runat="server" type="radio" name="rPaymentMethod" value="PayPal" />PayPal
http://www.somacon.com/p143.php
<input id="rCreditCard" runat="server" type="radio" name="rPaymentMethod" value="CreditCard" onclick="javascript:Reques torTypeCre ditCard(); " />CreditCard
<input id="rPayPal" runat="server" type="radio" name="rPaymentMethod" value="PayPal" onclick="javascript:Reques torTypePay Pal(); />PayPal
function RequestorTypeCreditCard()
{
document.Getelementid("Req uestorType ").item(0) .value = True;
document.getElementById("C reditClick ").value = "Y";
document.getElementById("p aypalclick ").value = "N";
somecode...............
}
Can you try this.
<input id="rCreditCard" runat="server" type="radio" name="rPaymentMethod" value="CreditCard" onclick="javascript:Reques
<input id="rPayPal" runat="server" type="radio" name="rPaymentMethod" value="PayPal" onclick="javascript:Reques
function RequestorTypeCreditCard()
{
document.Getelementid("Req
document.getElementById("C
document.getElementById("p
somecode...............
}
Can you try this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
full sample:
<script>
function getRadioValue(rgName){
var rbList = document.getElementsByName(rgName);
for (i=0;i<rbList.length;i++) if (rbList[i].checked) return rbList[i].value;
}
function chkPayment(){
var payment = getRadioValue("rPaymentMethod");
alert(payment);
}
</script>
<input id="rCreditCard" runat="server" type="radio" name="rPaymentMethod" value="CreditCard" />CreditCard
<input id="rPayPal" runat="server" type="radio" name="rPaymentMethod" value="PayPal" />PayPal
<button onClick="chkPayment()">Test</button>
Open in new window