Click to See Complete Forum and Search --> : select with radio button
anupriya
09-06-2006, 06:56 AM
hi friends............
In select functions there are four options such as
one
two (selected)
three
four
selected one in bold letters if selected "two" then i want to display radio buttons with that selected option "two".
one
two
three (selected)
four
as same as if i selected "three" then related to that it will display four radio buttons.
please i want the code for that in javascript i think it will using onchange function.
please if anyone send me an code for that....
thanks in advance
russell_g_1
09-06-2006, 02:07 PM
what are you after exactly?
when you select an option from your select, do you just want to change the radio buttons being shown?
is that right?
do the radio buttons have the same name or are they different for each select option?
Ribeyed
09-06-2006, 04:56 PM
also if you want the answer in javascript you need to post in that forum.
anupriya
09-07-2006, 01:48 AM
hi russell ......
ya same way if i select "two" the related to that data i want to display with radio button and when i selected "three" the related data want to display with radio button if u can.........
please how to write code for that
thanks russell
russell_g_1
09-10-2006, 07:44 AM
here's an example
<html>
<head>
<script language="javascript">
function setRadios(oSel)
{
var oDiv, value;
for (var i=0;i<oSel.options.length;i++)
{
value = oSel.options[i].value;
oDiv = document.getElementById("sel1_" + value);
if (oDiv != null)
oDiv.style.display = "none";
}
value = oSel.options[oSel.selectedIndex].value;
oDiv = document.getElementById("sel1_" + value);
if (oDiv != null)
oDiv.style.display = "block";
}
</script>
</head>
<body>
<form name="data">
<select name="sel1" onchange="setRadios(this);">
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
</select>
<div id="sel1_1">
<p>option 1 radios</p>
<input type="radio" value="1" name="sel1_1">abc
<input type="radio" value="2" name="sel1_1">def
</div>
<div id="sel1_2" style="display:none;">
<p>option 2 radios</p>
<input type="radio" value="1" name="sel1_2">ghi
<input type="radio" value="2" name="sel1_2">jkl
</div>
<div id="sel1_3" style="display:none;">
<p>option 3 radios</p>
<input type="radio" value="1" name="sel1_3">mno
<input type="radio" value="2" name="sel1_3">pqr
</div>
</body>
</html>
anupriya
09-13-2006, 05:35 AM
hello russell
thanks for helping me then another doubt ya please help me while i use submit button i want to display those selected values in option and radio buttons how its do for that......... please
thanks for helping russell i m new in javascript so only please reply to this question
russell_g_1
09-13-2006, 03:05 PM
are you saying you want the user to press a button to display the radio buttons instead of using the onchange event handler?
anupriya
09-14-2006, 01:47 AM
thats one is over but i use submit button while i click submit button the selected option like "option 1" and radio buttons like "abc" it will display in brower it should be identified as what user can selected. it should be display in separate window.