473,394 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Set Radiobuttonlist Value via Javascript

Hi all,

I have two radiobuttonlist controls on a page. When a user checks 'No' for
rblDeleted, I want to automatically set rblSendCard to 'No' and disable it.
The javascript function I wrote to do this 'appears' to work on the screen,
however, when the page is posted back and I check the value of rblSendCard,
it is an empty string when I expect it to be 'N'.
Of, course I can work around the problem by assuming 'N' when it is an empty
string, but would prefer to have the correct value posted back.

Can anyone tell me how to get it to work the way I expect or explain why it
can't.
Code is below.
TIA

<asp:radiobuttonlist id="rblSendCard" tabIndex="13" runat="server"
RepeatDirection="Horizontal" CellPadding="0"
CellSpacing="0" EnableViewState="False">
<asp:ListItem Value="Y">Yes</asp:ListItem>
<asp:ListItem Value="N">No</asp:ListItem>
</asp:radiobuttonlist>
<asp:radiobuttonlist id="rblDeleted" tabIndex="14" runat="server"
RepeatDirection="Horizontal" EnableViewState="False"
CellPadding="0" CellSpacing="0">
<asp:ListItem Value="Y">Yes</asp:ListItem>
<asp:ListItem Value="N" Selected="True">No</asp:ListItem>
</asp:radiobuttonlist>

<script language="JavaScript"> function SetDeleted() {
if(document.getElementById('U_Members1_rblDeleted_ 0').checked){
document.getElementById('U_Members1_rblSendCard_1' ).checked=true;
document.getElementById('U_Members1_rblSendCard'). disabled='disabled';}
else{
document.getElementById('U_Members1_rblSendCard'). disabled='';}}</script>

--

Alphonse Giambrone
Email: a-giam at customdatasolutions dot us

Nov 19 '05 #1
2 7034
When an html element is disabled, it is not posted in the Request.Forms
Collection.

bill
"Alphonse Giambrone" <NO**********@example.invalid> wrote in message
news:uZ**************@TK2MSFTNGP14.phx.gbl...
Hi all,

I have two radiobuttonlist controls on a page. When a user checks 'No' for
rblDeleted, I want to automatically set rblSendCard to 'No' and disable it. The javascript function I wrote to do this 'appears' to work on the screen, however, when the page is posted back and I check the value of rblSendCard, it is an empty string when I expect it to be 'N'.
Of, course I can work around the problem by assuming 'N' when it is an empty string, but would prefer to have the correct value posted back.

Can anyone tell me how to get it to work the way I expect or explain why it can't.
Code is below.
TIA

<asp:radiobuttonlist id="rblSendCard" tabIndex="13" runat="server"
RepeatDirection="Horizontal" CellPadding="0"
CellSpacing="0" EnableViewState="False">
<asp:ListItem Value="Y">Yes</asp:ListItem>
<asp:ListItem Value="N">No</asp:ListItem>
</asp:radiobuttonlist>
<asp:radiobuttonlist id="rblDeleted" tabIndex="14" runat="server"
RepeatDirection="Horizontal" EnableViewState="False"
CellPadding="0" CellSpacing="0">
<asp:ListItem Value="Y">Yes</asp:ListItem>
<asp:ListItem Value="N" Selected="True">No</asp:ListItem>
</asp:radiobuttonlist>

<script language="JavaScript"> function SetDeleted() {
if(document.getElementById('U_Members1_rblDeleted_ 0').checked){
document.getElementById('U_Members1_rblSendCard_1' ).checked=true;
document.getElementById('U_Members1_rblSendCard'). disabled='disabled';}
else{
document.getElementById('U_Members1_rblSendCard'). disabled='';}}</script>

--

Alphonse Giambrone
Email: a-giam at customdatasolutions dot us

Nov 19 '05 #2
Thanks for the quick reply, Bill.

That certainly explains it.

--

Alphonse Giambrone
Email: a-giam at customdatasolutions dot us
"William F. Robertson, Jr." <th****@nameht.org> wrote in message
news:eO**************@TK2MSFTNGP09.phx.gbl...
When an html element is disabled, it is not posted in the Request.Forms
Collection.

bill
"Alphonse Giambrone" <NO**********@example.invalid> wrote in message
news:uZ**************@TK2MSFTNGP14.phx.gbl...
Hi all,

I have two radiobuttonlist controls on a page. When a user checks 'No'
for
rblDeleted, I want to automatically set rblSendCard to 'No' and disable

it.
The javascript function I wrote to do this 'appears' to work on the

screen,
however, when the page is posted back and I check the value of

rblSendCard,
it is an empty string when I expect it to be 'N'.
Of, course I can work around the problem by assuming 'N' when it is an

empty
string, but would prefer to have the correct value posted back.

Can anyone tell me how to get it to work the way I expect or explain why

it
can't.
Code is below.
TIA

<asp:radiobuttonlist id="rblSendCard" tabIndex="13" runat="server"
RepeatDirection="Horizontal" CellPadding="0"
CellSpacing="0" EnableViewState="False">
<asp:ListItem Value="Y">Yes</asp:ListItem>
<asp:ListItem Value="N">No</asp:ListItem>
</asp:radiobuttonlist>
<asp:radiobuttonlist id="rblDeleted" tabIndex="14" runat="server"
RepeatDirection="Horizontal" EnableViewState="False"
CellPadding="0" CellSpacing="0">
<asp:ListItem Value="Y">Yes</asp:ListItem>
<asp:ListItem Value="N" Selected="True">No</asp:ListItem>
</asp:radiobuttonlist>

<script language="JavaScript"> function SetDeleted() {
if(document.getElementById('U_Members1_rblDeleted_ 0').checked){
document.getElementById('U_Members1_rblSendCard_1' ).checked=true;
document.getElementById('U_Members1_rblSendCard'). disabled='disabled';}
else{
document.getElementById('U_Members1_rblSendCard'). disabled='';}}</script>

--

Alphonse Giambrone
Email: a-giam at customdatasolutions dot us


Nov 19 '05 #3

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

Similar topics

2
by: Suresh.P.R | last post by:
Hi, While using the RadioButtonList control, that I populated in the runtime, I am not able to get the selected item in the javascript while referring document.Form.RadioButtonList.value. ...
6
by: Hazzard | last post by:
I store radiobuttonlist values in the db using the string value of the radio button item value. (nvarchar) I am creating an edit functionality on the asp.net form so that when I reuse my...
2
by: sramruttun | last post by:
hi I have a checkbox and a radiobuttonlist (the radiobuttonlist contains 2 items) in my form. The radiobuttonlist has its visible property set to false at design time. At run time, when the...
2
by: Sean | last post by:
Hi .... I have a radiobutton list and a label in a webform. <asp:radiobuttonlist id="one" runat="server" CssClass="text" AutoPostBack="False" RepeatDirection="Horizontal"> <asp:ListItem...
2
by: mg | last post by:
After a selection is made in the following RadioButtonList <asp:RadioButtonList id="RadioButtonList1" runat="server"> <asp:ListItem Value="Y"></asp:ListItem> <asp:ListItem...
5
by: DotNetGruven | last post by:
Anyone have any pointers on how to set the Value and Selected attributes in a ListItem in a RadioButtonList that is in a DataGrid? Here's what I have ------DataGrid------ -- BoundColumn 0 --...
6
by: DotNetGruven | last post by:
I have a webform that has a DataGrid on it with a RadioButtonList in each row. It is a simple On & Off. When the User Clicks on either of the RadioButtons, I need to postback to the server and...
4
by: Emil | last post by:
Can somebody tell me what would be the syntax for having an if statement and setting the selected index of a radiobuttonlist? This is my first project using ASP.net and I use C#. I have a repeater...
1
by: =?Utf-8?B?Qw==?= | last post by:
I have below. <asp:RadioButtonList ID="rblConfirm" runat="server"> <asp:listitem value="Yes">Yes</asp:listitem> <asp:listitem value="No">No</asp:listitem> </asp:RadioButtonList>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.