ASP.Net change radio button via javascript from onblur attribute

Please help. I have a radio button group with two buttons and one text box. If the user clicks into and then out of the text box I want to check if the user has changed the value from the default (which is 0) and if the user has changed the value I want the radio button to automatically switch to yes (which is the second item in the radio button group index).

I added the onblur attribute to my textbox and have tried to get the javascript going with all sorts of methods to no avail...

tbxBid.Attributes.Add("onblur", String.Format("CheckBoxChange(this.value,{0},{1});", tbxBox.ClientID, rdbGroup.ClientID))
 
    <script type="text/javascript">
        function CheckManualEntry(value, txtBoxName, rdbName) {
            var old_price = txtBoxName.getAttribute("value");
            var rb = document.getElementsByName(rdbName);
            rb[1].checked = true;
        }
    </script>

Open in new window

mrferrariAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle AbrahamsSenior .Net DeveloperCommented:

set your autopostback to true.
add an ontextchanged event handler.
AJAX it.
0
mrferrariAuthor Commented:
I want to use javasciprt. this is really small and simple. i cant figure it out though.

I don't want the page to autopostback...
0
Kyle AbrahamsSenior .Net DeveloperCommented:
http://dotnetslackers.com/articles/aspnet/JavaScript_with_ASP_NET_2_0_Pages_Part1.aspx

tbxBid.Attributes.Add("onblur",   PASTE_FUNCTION_HERE)

0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

ddayx10Commented:
I don't understand the scope beyond just the basics you outlined. I was a little confused by your attribute assignment in the code behind because you were calling on ID's that you hadn't mentioned in your question (tbxBid and tbxBox). All that is to say I may have missed the mark because I had to simplify without having more information...

Anyway this should give you an idea of how to begin managing the situation. I just wrote something that addresses the very specific things you mentioned. Of course I imagine you have a bigger scope and will have to update it accordingly...
0
ddayx10Commented:
didn't mean to post that (just hit the enter key on accident)...see snippet
****ASPX CODE****
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Change RadioButton</title>
    <script type="text/javascript">
		function CheckBoxChange(txtBx, rblID)
		{
			if(txtBx.value != '0')
			{
				var rblParent = document.getElementById(rblID);
				var rbl = rblParent.getElementsByTagName('input');
				rbl[0].checked = true;
			}
		}
    </script>
</head>
<body>
    <form id="form1" runat="server">
 
		<span>Default Text Box</span>
		<asp:TextBox ID="tbxBid" runat="server" Text="0" />
 
		<asp:RadioButtonList ID="rdbGroup" runat="server">
			<asp:ListItem Value="0" Text="Yes" />
			<asp:ListItem Value="1" Text="No" />
		</asp:RadioButtonList>
		
		
    </form>
</body>
</html>
 
 
****CODE BEHIND****
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
        If Not IsPostBack Then
            'Keep in mind that if you are using an asp:radiobuttonlist then the tdbGroup.clientID you are sending below
            'is actually a table, and you have to use that to get at the radiobuttons inside
            tbxBid.Attributes.Add("onblur", String.Format("CheckBoxChange(this,'{0}');", rdbGroup.ClientID))
        End If
 
    End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mrferrariAuthor Commented:
bingo bango... that works great. thanks so much...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.