Solved

Drop down & Radio buttons

Posted on 2003-11-25
6
741 Views
Last Modified: 2010-04-09
Hi,
     I am a small problem in HTML.
     I am a radio button & when one checks that button, he is supposed to enter some data from 3 drop down boxes & then proceed.
     But my requirement is such that unless that radio button is checked, the dropdown box is inactive, meaning the no data in the drop down can be viewed or selected. Only when the radio buttons r selected are the drop down data available for viewing & selection.
     Can anyone suggest a way out !
0
Comment
Question by:medebayan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:xabi
ID: 9823128
What about this?

<html>
<head>
<title>Sample</title>
</head>
<body>
<form name="myform">
<input type="checkbox" name="mycheck" onclick="this.form.myselect.disabled=!this.checked"><br>
<select name="myselect" disabled>
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
</form>
</body>
</html>

xabi
0
 

Author Comment

by:medebayan
ID: 9823211
I don't think this will solve my problem.
Firstly, there r 2 RADIO BUTTONS. One when selected needs inputs from drop downs, which are populated from the database.
Now, mayb u can provide me with an accurate solution !
0
 
LVL 7

Expert Comment

by:gam3r_3xtr3m3
ID: 9823613
dynamically, here's a solution:

<script language="JavaScript" type="text/javascript">
function enableSelect(){
if(document.theform.selectbox.disabled=true){
document.theform.selectbox.disabled=false;}}
</script>
<body>
<form name="theform">
<input type="radio" onClick="enableSelect();" name="radio1" value="Selection #2">Selection #1<br />
<input type="radio" onClick="enableSelect();" name="radio1" value="Selection #2">Selection #2<br />
<select name="selectbox" disabled="disabled">
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
</body>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Accepted Solution

by:
gam3r_3xtr3m3 earned 70 total points
ID: 9823676
OR if your doing a confirmation dynamically like this...:

<html>
<head>
<title>2 radio buttons and a checkbox!</title>
<script language="JavaScript" type="text/javascript">
function checkStat(){
if(document.theform.radio1.checked="undefined"){
alert("Please select a choice!"); return false;}}
function enableSelect(){
if(document.theform.selectbox.disabled=true){
document.theform.selectbox.disabled=false;}
if(document.theform.sbmtbtn.disabled=true){
document.theform.sbmtbtn.disabled=false;}}
function disableSelect(){document.theform.selectbox.disabled=true;}
</script>
</head>
<body>
<div align="center">
<form name="theform" onSubmit="return checkStat();">
<input type="radio" onClick="enableSelect();" name="radio1" value="y" />Add to Database<br />
<input type="radio" onClick="disableSelect();" name="radio1" value="n" />Don't do anything<br />
<select name="selectbox" disabled="disabled">
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
<br /><input type="submit" name="sbmtbtn" value="submit" disabled="disabled" />
</div>
</body>
</html>
0
 
LVL 7

Expert Comment

by:gam3r_3xtr3m3
ID: 9823710
lol... i got the title wrong, the coding wrong and i forgot to take of my test checkStat(); function. Too much VB for me. lol... here's mabye a set of all you need:

<html>
<head>
<title>2 radio buttons and a option box!</title>
<script language="JavaScript" type="text/javascript">
var cont1=null;
function loadStat(){
if(document.theform.radio1.selected==true){enableSelect();}}
function checkStat(){
if(cont1=="y"){
alert("Select a database!");return false;}}
function enableSelect(){
cont1="y";
if(document.theform.selectbox.disabled==true){
document.theform.selectbox.disabled=false;}
if(document.theform.sbmtbtn.disabled==true){
document.theform.sbmtbtn.disabled=false;}}
function disableSelect(){
cont1="n";
if(document.theform.selectbox.disabled==false){
document.theform.selectbox.disabled=true;}
if(document.theform.sbmtbtn.disabled==true){
document.theform.sbmtbtn.disabled=false;}}
</script>
</head>
<body onLoad="loadStat();">
<div align="center">
<form name="theform" onSubmit="return checkStat();">
<input type="radio" onClick="enableSelect();" name="radio1" value="y" />Add to Database<br />
<input type="radio" onClick="disableSelect();" name="radio1" value="n" />Don't do anything<br />
<select name="selectbox" disabled="disabled">
<option>Please select one...</option>
<option value="db1">database 1</option>
<option value="db2">database 2</option>
<option value="db3">database 3</option>
</select>
<br /><input type="submit" name="sbmtbtn" value="Submit" disabled="disabled" />
</div>
</body>
</html>
0
 

Author Comment

by:medebayan
ID: 9823763
Thanx a lot ! This should serve my need..
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question