mardi 4 août 2015

Javscript is not hiding div & input element

I've got a div & input that needs to be hidden on the page load. It is a other specify, so if one of the other fields is selected "other" then the div should show. But the input element is not hiding on page load. As soon as I take out the input element from the div it hides, but as soon as I put the input element back it does not hide, what am I doing wrong?

<head>
<script>
function hideother() {
    document.getElementById("otherdiv").style.visibility = "hidden";
    document.getElementById("others").style.visibility = "hidden";
}
</script>
</head>

<body onLoad="hideother()">
    <!-- 2A OTHER SPECIFY -->
    <div class="otherdiv">
    <label for="otherspecify">Please specify other:</label>
    <label id="error-2" style="text-transform:capitalize; color:red">&nbsp;</label>
    <br>
<input maxlength="30" name="others" id="others" type="text" class="form-control" placeholder="Other Specify" autocomplete="off" style="width:300px" />
    </div>
</body>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire