473,657 Members | 2,395 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Radio Button List server control and java script

How can i check in java script if a asp.net radio button
list server control is selected?

I have some custom javascript function in the client side
that needs to run but I don't see the way to see if user
selected or not one of the options....

thanks,
jayuya
Nov 17 '05 #1
2 9853
The aspx control obviously renders as normal HTML. Use
the ID/Name of the html control as usual.

An easy way to get the HTML name:
htmlName=replac e(RadioButtonCo ntrol.UniqueNam e,":","_")

-----Original Message-----
How can i check in java script if a asp.net radio button
list server control is selected?

I have some custom javascript function in the client side
that needs to run but I don't see the way to see if user
selected or not one of the options....

thanks,
jayuya
.

Nov 17 '05 #2
Hi

Example ( Should work... I did not check :) )

Replace FORMNAME/RADIONAME with yours
<html>
<head>
<script language="JavaS cript">
function checkRadio(){
var bIsChecked = false;
var r = document.forms["myForm"].r1;
for(i=0;i<r.len gth;i++)
{
if( r[i].checked )
{
bIsChecked = true;
break;
}
}
if(!bIsChecked ) alert("Please check.... ");
return bIsChecked;
}
</script>
</head>
<body>
<form name="myForm">
<input type="radio" name="r1">
<input type="radio" name="r1">
<input type="radio" name="r1">
<input type="radio" name="r1">
<input type="radio" name="r1">
<input type="submit" onclick="return checkRadio()" value="Click to test
radio">
</form>
</body>
</html>

Note if for some reason the list has only 1 item the length will be
undefined.

And also we have a good group for client issues
microsoft.publi c.scripting.jsc ript

--
Best Regards
Vidar Petursson
=============== ===============
Microsoft Internet Client & Controls MVP
=============== ===============
"jayuya" <ja****@cox.net > wrote in message
news:03******** *************** *****@phx.gbl.. .
How can i check in java script if a asp.net radio button
list server control is selected?

I have some custom javascript function in the client side
that needs to run but I don't see the way to see if user
selected or not one of the options....

thanks,
jayuya

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8746
by: Michael Albanese | last post by:
I am developing an application to handle my compay's OSHA reporting requirements. Some of the input criteria are technical and narowly defined, so I was trying to prvide what i call "Context Sensitive Help" by providing a short instructional message based on which control has Focus. Because of the way that a Radio Button List control is rendered in the browser i can not attach an onFocus event
4
4103
by: mitch-co2 | last post by:
What I am trying to do is when someone clicks on the YES radio button I want the text field called MYTEXT to equal the text field named DATE. The below code works as long as I do NOT UN-COMMENT the NO radio button, once I do that it will not work. Any help would be greatly appreciated. Mitch
3
2351
by: ewitkop90 | last post by:
Here is my code: <SCRIPT> function transportchange(transport) { if (framenewinstall.Helpdesk.checked) framenewinstall.Helpdesk.checked=false; if (framenewinstall.CircuitNumber.checked) framenewinstall.CircuitNumber.checked=false; switch (transport) { case 0: Helpdesk.innerText="No Info Needed";
2
3476
by: NishSF | last post by:
Would anyone have any suggestions/javascript code so that if one clicks the Radio Button "Yes" below he has the option of selecting any of the six CheckBox below. If the user clicks on Radio Button "No", he should not have the option of clicking on any of the six checkboxes. See Code attached. Thank you so much in advance for your help as I can't get to make this combo work. <p>Did you have any problems finding any of the information...
2
2297
by: xazos79 | last post by:
Hi All, I've come across the problem of not being able to re-enable a radio button with javascript if its initial state has been disabled in the Page_Load() method of the code behind. Might i add that it behaves fine in Firefox, but IE is unable to re-enable the radio button. IE is fine if the radio button starts in an enabled state.
0
1405
by: Shadow Lynx | last post by:
In standard HTML, the <INPUT type="radio" name="x" /control only allows one radio button to be checked at a time. When more than one are set as checked="true" then only the last one rendered appears as checked. I would assume that asp:RadioButton objects that share the same GroupName would not allow more than one Radio Button to be checked (similar to the Radio Button List) but it seems to not be the case. If I set one Radio Button's...
10
6074
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio button with this link of code: echo 'SCRIPT language=JavaScript setCheckedValue("'.$_SESSION.'");</SCRIPT>'; //? <snip of code>
3
2307
by: Chris Marsh | last post by:
Hello, Is it possible w/ASP.Net to set the property of the radio button control to 'read-only' after the user has made their selection before hitting an 'submit' button? Think of a multiple choice question, in our case it's 'Accept', 'Not Accept' or 'Pending' in a grid column. There are multple rows in the grid maybe 2, 3 or even 10 rows and we want to make it so that the user, when they select 'Accept' in say the second row that the...
3
11301
by: shanmukhi | last post by:
Hi All, how to control the selection of radio buttons in jsp. i think i have to write java script for that.. my code is like this <form name="form1"> <input type="radio" name="male">Male <input type="radio" name="female">Female <input type="submit" value="submit">
0
8394
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8306
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7327
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4152
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.