We help IT Professionals succeed at work.

ASP.Net change radio button via javascript from onblur attribute

mrferrari
mrferrari asked
on
Medium Priority
1,207 Views
Last Modified: 2012-05-07
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

Comment
Watch Question

Kyle AbrahamsSenior .Net Developer
CERTIFIED EXPERT

Commented:

set your autopostback to true.
add an ontextchanged event handler.
AJAX it.

Author

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...
Kyle AbrahamsSenior .Net Developer
CERTIFIED EXPERT

Commented:
http://dotnetslackers.com/articles/aspnet/JavaScript_with_ASP_NET_2_0_Pages_Part1.aspx

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

Commented:
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...
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
bingo bango... that works great. thanks so much...
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.