Display or enable/disable radio button based on response from another radio button

Hi, I am working on this project where I am dynamically creating a radio button based on the database values. I am using HTML, ASP and COM Components. The portion where I grab the data from the database is working fine. <% For i = 1 to varDriverCount %> <input type="radio" name="Design" value="<% = varArrayInfo(2,i,0) %>" <% If varArrayInfo(2,i,0) = radDesign Then Response.Write "Checked" %> ID="Radio1"> <a href="/Design<%=i%>.gif"><%Response.Write varArrayInfo(0,i,0) & " " & varArrayInfo(1,i,0)%></a></td> The above portion of dynamically creating radio buttons based on the array that contains the values from the database is also working fine. varArrayInfo(0,i,0) would contain the First Name of the person who created design. varArrayInfo(1,i,0) would contain the Last Name of the person who created design. varArrayInfo(2,i,0) would contain the value of the design i.e; 1. varArrayInfo(3,i,0) contains the values for another radio button "Style". Based on what the customer clicks for "Design" radio button, I need to display or enable/disable another radio button "Style" if the value of varArrayInfo(3,i,0) is 1 because only on certain instances I need to display that "Style" radio button for ex; only if the database has the value 1. I am not sure what would be the best way to accomplish this. Please advice! Thanks!!

Answer Wiki

Thanks. We'll let you know when a new response is added.

If you want to hide/unhide a radio button based on user response to another event, then best way to do it
is to use client side scritpting such as javascript.

For example in your code for defining the radio button “Design” Add an event handler such as OnClick or OnBlur to call a javascript function which can hide or unhide the HTML code which defines the “Style” radio button. However I would suggest to name the button something else than Style as Style is also a reserved word used for defining HTML Styles for texts, buttons etc.

Following is the brief outline of the code that you may have for this purpose:

<input type=”radio” name=”Design” OnClick=”DisplayStyle()” value=” …..>

<Div id=”GetStyles” Style=”Visibility:Hidden”>
<input type=”radio” name=”DesignStyles” id=”DesignStyles” ….. >

<script language=”javascript”>

function DisplayStyle()
document.all.GetStyles.style.visibility = “visible”;

function HideStyle()
document.all.GetStyles.style.visibility = “hidden”;


Discuss This Question: 1  Reply

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • NigelMcFarlane
    JavaScript is the way to go, as the other response noted. If you just want to disable, rather than hide, the optional input, then you can set or unset the disabled attribute on it: window.formX.fieldY.setAttribute("disabled","true"); window.formX.fieldY.removeAttribute("disabled");
    0 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: