C
C
cactuss2014-04-21 22:17:03
css
cactuss, 2014-04-21 22:17:03

Sequential selection, how to make a check?

<script>
    function a() {document.getElementById('info1').style.display='block';}
    function b() {document.getElementById('info2').style.display='block';}
    function c() {document.getElementById('info3').style.display='block';}
</script>

<input   type="radio" name="1"   onChange="a()">1
<input   type="radio" name="1"   onChange="b()">2
<input   type="radio" name="1"   onChange="c()">3
<br>
    <div id="info1" style="display:none">
        <label><input name="2" type="radio" value="Да" />1Да</label>
        <label><input name="2" type="radio" value="Нет" />1Нет</label>
    </div>
    <div id="info2" style="display:none">
        <label><input name="3" type="radio" value="Да" />2Да</label>
        <label><input name="3" type="radio" value="Нет" />2Нет</label>
    </div>
    <div id="info3" style="display:none">
        <label><input name="4" type="radio" value="Да" />3Да</label>
        <label><input name="4" type="radio" value="Нет" />3Нет</label>
    </div>
</form>

Help, I've been fiddling with this for 2 hours now.
js I don't know well, c++ won't help... How to implement a check so that if the 1st option is selected, the 2nd one is not displayed? As in the screenshot
d5c14a73e01a4906be120a9828ea9f57.PNG
This is how it should be...
24eafd7c02aa40b19ed537419d81b41f.PNG
c94abd5b0b504c9b85056ebebc2369a0.PNG
Write a check for me, please. I did not succeed (

Answer the question

In order to leave comments, you need to log in

1 answer(s)
1
1001001 111, 2014-04-22
@cactuss

Create a function like this

var elems = document.getElementsByTagName("div");
for (var i = 0; i<elems.length; i++) {
     elems[i].style.display = 'none';
}

and call it at the very beginning in functions (a, b, c).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question