• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple Radio Objects

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can someone please help me or refer me to a book about multiple Radio Objects
like example below
ABC
� Standard
� Days Hours TEXTFELD��

Odeon
Location
City

ABC and Odeon are the mainRadioButtons
and Standard, Days, Location and city are SubRadionButtons
When ABC is selected you should be able to select either Standard or Days - if standard is selected hours Textfield should be disabled.
If Odeon is selected - ABC should be unselected and the suboptions disabled.
Thanks,
Toto


 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Toto,
Welcome to the Ranch!
You are going to need to change your name to conform to Ranch Standards, but in the meantime here's an answer.
The trick to using radio buttons is to make sure that all the buttons in a single group have the same name, and are distinguished among themselves by unique values.
You can use the onchange handler to detect when the various buttons are selected and modify the enabled/disabled state of related controls as appropriate.
hth,
bear
[ May 29, 2003: Message edited by: Bear Bibeault ]
 
Maggie Toshi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear for quick response. I will change my Name.
If I use the same name for radios I can only select one - I want to be able to select main and then sub.
Thanks Much
Toto
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at this code and see if it helps
<html>
<head>
<script>
function AllowSub(X){
if(X)How=false;
else How=true;
for(i=0;i<document.E.R2.length;i++){
document.E.R2[i].disabled=How;
}


}
</script>
</head>
<body>
<form name="E">
<input type="radio" value="V1" name="R1" onfocus="AllowSub(true)">Allows Sub<br>
<input type="radio" value="V2" name="R1" onfocus="AllowSub(false)">Not Allow Sub<br>
<input type="radio" value="V3" name="R1" onfocus="AllowSub(false)">Not Allow Sub<br>
<input type="radio" value="V4" checked name="R1" onfocus="AllowSub(false)">Not Allow Sub
<blockquote>
<p><input type="radio" name="R2" value="V1" disabled>Sub<br>
<input type="radio" name="R2" value="V2" disabled>Sub<br>
<input type="radio" name="R2" value="V3" disabled>Sub<br>
</p>
</blockquote>
</form>
</body>
</html>

Eric
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric's example is exactly what I was talking about: give the same name to each group of related radio buttons.
Thanks Eric!
bear
 
Maggie Toshi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric and Bear,
Thank you soo much for your help. That worked but I am not able to reset the values - can you please look into these and any help will be really appreciated.
<html>
<head>
<script>
function AllowSub(X)
{
if(X)How=false;
else How=true;
for(i=0;i<document.E.subOptions.length;i++)
{
document.E.subOptions[i].disabled=How;
}
}
</script>
</head>
<body>
<form name="E">
<table height="74" cellSpacing="0" cellPadding="0" width="787" border="0">
<tbody>
<tr>
<td width="58" height="1"> </td>
<td align="left" width="19" height="1"><input type="radio" name="options" onfocus="AllowSub(true)"></td>
<td align="left" width="704" colSpan="3" height="1">Test</td>
</tr>
<tr>
<td width="58" height="21"> </td>
<td width="19" height="21"> </td>
<td align="right" width="18" height="21"><input type="radio" name="subOptions" disabled></td>
<td align="left" width="684" colSpan="2" height="21">ABC</td>
</tr>
<tr>
<td width="58" height="25"> </td>
<td width="19" height="25"> </td>
<td align="right" width="18" height="25"><input type="radio" name="subOptions" disabled></td>
<td align="left" width="88" height="25">Quiz</td>
<td width="594" height="25">Answer  <input maxLength="4" size="18" name="flexHrsPerWeek"></td>
</tr>
<tr>
<td width="785" colSpan="5" height="21"> </td>
</tr>
<tr>
<td width="58" height="44"> </td>
<td align="left" width="19" height="44"><input type="radio" name="options" onfocus="AllowSub(false)"></td>
<td align="left" width="108" colSpan="2" height="44">Exam</td>
<td width="594" height="44">Location <input maxLength="40" size="20" name="jobShareName"></td>
</tr>
<tr>
<td width="785" colSpan="5" height="21"> </td>
</tr>
<tr>
<td width="58" height="21"> </td>
<td align="left" width="19" height="21"><input type="radio" name="options" onfocus="AllowSub(true)"></td>
<td align="left" width="704" colSpan="3" height="21">Grade</td>
</tr>
<tr>
<td width="58" height="30"> </td>
<td width="19" height="30"> </td>
<td align="right" width="18" height="30"><input type="radio" name="subOptions" disabled ></td>
<td align="left" width="88" height="30"> Pass</td>
<td width="594" height="30"> </td>
</tr>
<tr>
<td width="58" height="21"> </td>
<td width="19" height="21"> </td>
<td align="right" width="18" height="21"><input type="radio" name="subOptions" disabled></td>
<td align="left" width="88" height="21">Fail</td>
<td width="594" height="21"> </td>
</tr>

</tbody>
</table>

</body>
</form>
</html>
reply
    Bookmark Topic Watch Topic
  • New Topic