select an option with multiple select

1

What I want is that when there are several selections, each one changes an id, I do not know if I explain it, I want to select an input and if this permission disappears the input will be several select

<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {
    border: 1px solid black;
    margin: 5px;
}
</style>
</head>
<body>

<div id="myDIV">
  <h3>A h3 element in div.</h3>
  <p>P element in div.</p>
  <span>A span element in div.</span>
  <h2>A h2 element in div.</h2>
  <div>A div element in div.</div>
  <p>Another p element in div.</p>
</div>
<div id="myDIV">
  <h3>A h3 element in div.</h3>
  <p>P element in div.</p>
  <span>A span element in div.</span>
  <h2>A h2 element in div.</h2>
  <div>A div element in div.</div>
  <p>Another p element in div.</p>
</div>

<p>Click the button to add a background color to all elements inside the div element.</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
    var x = document.getElementById("myDIV");
    var y = x.getElementsByTagName("p");
    var i;
    for (i = 0; i < y.length; i++) {
        y[i].style.backgroundColor = "red";
    }
}
</script>

<select name="condicion" onchange="myFunction(this.value)">
                                    <option value="1">PRESENTE</option>
                                    <option value="2">PERMISO</option>
                                </select>

<select name="condicion" onchange="myFunction(this.value)">
                                    <option value="1">PRESENTE</option>
                                    <option value="2">PERMISO</option>
                                </select>
</body>
</html>
    
asked by Francisco Ninus 21.10.2016 в 01:39
source

1 answer

-1

You must place a different id or name to the selects that you already have created in order to distinguish them in your code. Then, you create the input you want to show, but within its CSS attributes you set it "visibility: hidden" or "display: none". Then, within your Javascript code, questions with an if-else for the value of the parameter that you sent to the function. If you fulfill the condition you want, you change the visibility value of the input or not. I hope it helps you.

    
answered by 22.10.2016 в 01:37