On my form I have aradio button group that when it runs it will disable the textbox field and make the value null. My problem is determining which radio button was selected from the group. I trie dto set teh value of he radio button in the if statement but
it seems to ignore it.
It appears to be working fine - however I made a few changes to your mark-up. You'll need to make sure that all of your tags have proper closing tags (this is espeically important in IE)
Strange. I just tried the example that I had used previously in Firefox and it worked just fine. What does your HTML look like after it has been rendered (View Source)
I'm wondering if you have something being generated within your code blocks <% %> that it doesn't like.
The previously posted JSBin example was working in Chrome when I wrote it. I may have accidentally overridden it. I'll check it when I get home and if need remake it to get it working for you.
I'll give it a try in the morning when I'm back in the office. I'm thinking I should have written the if statement different to recognize if the first it second radio button was selected. Thanks so much for your assistance.
rsvore
Member
324 Points
286 Posts
javascript which radio button group selected.
Jan 30, 2013 07:03 PM|LINK
On my form I have aradio button group that when it runs it will disable the textbox field and make the value null. My problem is determining which radio button was selected from the group. I trie dto set teh value of he radio button in the if statement but it seems to ignore it.
I currently have this javascript function call:
function disablefields() { if (document.getElementById('App_Domestic_Foreign').checked) { document.getElementById('App_Foreign_Amt').value = ''; document.getElementById('App_Foreign_Amt').disabled = 'disabled'; document.getElementById('App_Foreign_Amt_Currency').value = ''; document.getElementById('App_Foreign_Amt_Currency').disabled = 'disabled'; document.getElementById('App_USD_Amt').disabled = ''; document.getElementById('App_USD_Amt_Currency').disabled = ''; alert("part 1"); } else { document.getElementById('App_USD_Amt').value = ''; document.getElementById('App_USD_Amt').disabled = 'disabled'; document.getElementById('App_USD_Amt_Currency').value = ''; document.getElementById('App_USD_Amt_Currency').disabled = 'disabled'; document.getElementById('App_Foreign_Amt').disabled = ''; document.getElementById('App_Foreign_Amt_Currency').disabled = ''; alert("part 2"); } }and this is the input fields:
<table celpadding=0 cellspacing=0 BORDER=0 width=686> <tr> <td COLSPAN=5> <FONT SIZE="2" FACE="MS SANS SERIF, SANS SERIF, HELVETICA">Date:<FONT SIZE="2"> <input class="text_area" type="text" name="App_Date" size=8 maxlength="8" value="<%=Todays_Date%>"></TD> </tr> <Tr> <TD width=35><input type=RADIO name="App_Domestic_Foreign" onclick="disablefields();" VALUE="Domestic" <%If request("App_Domestic_Foreign") = "Domestic" then response.write("Checked") End If%>></TD> <TD width=152><FONT SIZE="2" FACE="MS SANS SERIF, SANS SERIF, HELVETICA">($) USD Amount:</td> <TD width=135><input type=text size=10 maxlength=10 id="App_USD_Amt" <% If request("App_Foreign_Amt") <> "" then response.write("disabled=disabled") else response.write("") End If %> name="App_USD_Amt" VALUE="<%=request("App_USD_Amt")%>" onkeypress="return(currencyFormat(this,',','.',event))" </td> <TD width=231><FONT SIZE="2" FACE="MS SANS SERIF, SANS SERIF, HELVETICA">and (Optional:convert to currency type/countr):</TD> <TD width=123><input type=text size=10 maxlength=10 id="App_USD_Amt_Currency" <% If request("App_Foreign_Amt") <> "" then response.write("disabled=disabled") else response.write("") End If %> name="App_USD_Amt_Currency" onkeypress="return(currencyFormat(this,',','.',event))" VALUE="<%=request("App_USD_Amt_Currency")%>"> </TD> </tr> <TR> <TD width=35><input type=RADIO id="App_Domestic_Foreign" name="App_Domestic_Foreign" onclick="disablefields();" VALUE="Foreign" <%If request("App_Domestic_Foreign") = "Foreign" then response.write("Checked") End If%>></TD> <TD width=152><FONT SIZE="2" FACE="MS SANS SERIF, SANS SERIF, HELVETICA">Foreign Amount:</TD> <TD width=135><input type=text size=10 maxlength=10 id="App_Foreign_Amt" <% If request("App_USD_Amt") <> "" then response.write("disabled=disabled") else response.write("") End If %> name="App_Foreign_Amt" VALUE="<%=request("App_Foreign_Amt")%>" onkeypress="return(currencyFormat(this,',','.',event))"></TD> <TD width=231><FONT SIZE="2" FACE="MS SANS SERIF, SANS SERIF, HELVETICA">and (specify currency type/country):<FONT SIZE="2"></TD> <TD width=123><input type=text size=10 maxlength=10 id="App_Foreign_Amt_Currency" <% If request("App_USD_Amt") <> "" then response.write("disabled=disabled") else response.write("") End If %> name="App_Foreign_Amt_Currency" onkeypress="return(currencyFormat(this,',','.',event))" VALUE="<%=request("App_Foreign_Amt_Currency")%>"> </TD> </tr> </table>Rion William...
All-Star
26445 Points
4389 Posts
Re: javascript which radio button group selected.
Jan 30, 2013 07:23 PM|LINK
It appears to be working fine - however I made a few changes to your mark-up. You'll need to make sure that all of your tags have proper closing tags (this is espeically important in IE)
Example
I went through and cleaned up your mark-up a bit, so give this a try :
<table celpadding=0 cellspacing=0 BORDER=0 width=686> <tr> <td COLSPAN=5> <font SIZE="2" FACE="MS SANS SERIF, SANS SERIF, HELVETICA">Date:</font> <input class="text_area" type="text" name="App_Date" size=8 maxlength="8" value="<%=Todays_Date%>" /> </td> </tr> <tr> <td width=35> <input type=RADIO name="App_Domestic_Foreign" onclick="disablefields();" VALUE="Domestic" <%If request("App_Domestic_Foreign") = "Domestic" then response.write("Checked") End If%> /> </td> <td width=152> <font SIZE="2" FACE="MS SANS SERIF, SANS SERIF, HELVETICA">($) USD Amount:</font> </td> <td width=135> <input type=text size=10 maxlength=10 id="App_USD_Amt" <% If request("App_Foreign_Amt") <> "" then response.write("disabled=disabled") else response.write("") End If %> name="App_USD_Amt" VALUE="<%=request("App_USD_Amt")%>" onkeypress="return(currencyFormat(this,',','.',event))" /> </td> <td width=231> <font SIZE="2" FACE="MS SANS SERIF, SANS SERIF, HELVETICA">and (Optional:convert to currency type/countr):</font> </td> <td width=123> <input type=text size=10 maxlength=10 id="App_USD_Amt_Currency" <% If request("App_Foreign_Amt") <> "" then response.write("disabled=disabled") else response.write("") End If %> name="App_USD_Amt_Currency" onkeypress="return(currencyFormat(this,',','.',event))" VALUE="<%=request("App_USD_Amt_Currency")%>" / > </td> </tr> <tr> <td width=35> <input type=RADIO id="App_Domestic_Foreign" name="App_Domestic_Foreign" onclick="disablefields();" VALUE="Foreign" <%If request("App_Domestic_Foreign") = "Foreign" then response.write("Checked") End If%> /> </td> <td width=152> <font SIZE="2" FACE="MS SANS SERIF, SANS SERIF, HELVETICA">Foreign Amount:</font> </td> <td width=135> <input type=text size=10 maxlength=10 id="App_Foreign_Amt" <% If request("App_USD_Amt") <> "" then response.write("disabled=disabled") else response.write("") End If %> name="App_Foreign_Amt" VALUE="<%=request("App_Foreign_Amt")%>" onkeypress="return(currencyFormat(this,',','.',event))" /> </td> <td width=231> <font SIZE="2" FACE="MS SANS SERIF, SANS SERIF, HELVETICA">and (specify currency type/country):</font> </td> <td width=123> <input type=text size=10 maxlength=10 id="App_Foreign_Amt_Currency" <% If request("App_USD_Amt") <> "" then response.write("disabled=disabled") else response.write("") End If %> name="App_Foreign_Amt_Currency" onkeypress="return(currencyFormat(this,',','.',event))" VALUE="<%=request("App_Foreign_Amt_Currency")%>" /> </td> </tr> </table>rsvore
Member
324 Points
286 Posts
Re: javascript which radio button group selected.
Jan 30, 2013 07:46 PM|LINK
Thanks for cleaning up my mess.
It works fine in IE but it works just the opposite in Firfox any ideas why?
Rion William...
All-Star
26445 Points
4389 Posts
Re: javascript which radio button group selected.
Jan 30, 2013 07:52 PM|LINK
Strange. I just tried the example that I had used previously in Firefox and it worked just fine. What does your HTML look like after it has been rendered (View Source)
I'm wondering if you have something being generated within your code blocks <% %> that it doesn't like.
rsvore
Member
324 Points
286 Posts
Re: javascript which radio button group selected.
Jan 30, 2013 08:16 PM|LINK
I found a clue the radio button value i snot defined when the onclick function in the radio button is called
rsvore
Member
324 Points
286 Posts
Re: javascript which radio button group selected.
Jan 30, 2013 08:42 PM|LINK
I ran your example in chrome and it didn't work.
rsvore
Member
324 Points
286 Posts
Re: javascript which radio button group selected.
Jan 30, 2013 09:43 PM|LINK
I ended up checking for the browser the executed teh javascript depending on which browser the page was being viewed. Seems to work.
Rion William...
All-Star
26445 Points
4389 Posts
Re: javascript which radio button group selected.
Jan 30, 2013 11:29 PM|LINK
Rion William...
All-Star
26445 Points
4389 Posts
Re: javascript which radio button group selected.
Jan 31, 2013 12:36 AM|LINK
So this example wasn't working in Chrome?
rsvore
Member
324 Points
286 Posts
Re: javascript which radio button group selected.
Jan 31, 2013 12:44 AM|LINK