I've created a control which has 3 radio buttons and a text box. It looks roughly like this:
Fee Type
-------------
0 Gross Margin
0 Cost Markup
0 Flat Rate
Fee Rate
-------------
___________________
|___________________|
If the user selects one of the first 2 options, the textbox needs to be filled with a percentage (0-100). If the user selects the Flat Rate option, the textbox will have a currency value.
What I'd like to do is format the number entered in the textbox as a currency if option #3 is selected in the radio box. I've done this successfully on other textboxes that require currencies, but can't seem to make it conditional on which radio button is selected.
I'd like to wrap an IF THEN statement around the FormatCurrency line to only execute if the 3rd radio button has been selected, but I can't seem to reference it.
This is how the browser renders the radio buttons:
I keep getting an invalid character error at the underscore when I try to reference the button using OpportunityForm._ctl3_SellPriceCalculator_lblFeeTypeRadio_2. Any suggestions on how I can tell which button has been selected in my VBScript onBlur function?
Fee Type
-------------
0 Gross Margin
0 Cost Markup
0 Flat Rate
Fee Rate
-------------
___________________
|___________________|
If the user selects one of the first 2 options, the textbox needs to be filled with a percentage (0-100). If the user selects the Flat Rate option, the textbox will have a currency value.
What I'd like to do is format the number entered in the textbox as a currency if option #3 is selected in the radio box. I've done this successfully on other textboxes that require currencies, but can't seem to make it conditional on which radio button is selected.
Code:
<script language="VBScript">
sub ConvertFeeDoubletoCurrency(field)
if IsNumeric(field.value) then
field.value = FormatCurrency(field.value)
else
alert("A numeric value must be entered")
field.focus
end if
end sub
</script>
<asp:RadioButtonList id="lblFeeTypeRadio" runat="server">
<asp:ListItem text="Gross Margin %" value="0" />
<asp:ListItem text="Cost Markup %" value="1" />
<asp:ListItem text="Flat Rate" value="2" />
</asp:RadioButtonList>
<asp:textbox id="lblFeeRate" onBlur="ConvertFeeDoubletoCurrency(this)"
runat="server"></asp:Textbox>
I'd like to wrap an IF THEN statement around the FormatCurrency line to only execute if the 3rd radio button has been selected, but I can't seem to reference it.
This is how the browser renders the radio buttons:
Code:
<input id="_ctl3_SellPriceCalculator_lblFeeTypeRadio_0" type="radio"
name="_ctl3:SellPriceCalculator:lblFeeTypeRadio" value="0" />
<input id="_ctl3_SellPriceCalculator_lblFeeTypeRadio_1" type="radio"
name="_ctl3:SellPriceCalculator:lblFeeTypeRadio" value="1" checked="checked" />
<input id="_ctl3_SellPriceCalculator_lblFeeTypeRadio_2" type="radio"
name="_ctl3:SellPriceCalculator:lblFeeTypeRadio" value="2" />
I keep getting an invalid character error at the underscore when I try to reference the button using OpportunityForm._ctl3_SellPriceCalculator_lblFeeTypeRadio_2. Any suggestions on how I can tell which button has been selected in my VBScript onBlur function?