Try using Jquery, Here is code:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
function myFunction(){
alert('You have chosen: '+$("#otherText").val());
}
function checkIfOther()
{
$("#otherText").val('');
($("#dropDown1").val() == 'other') ? $("#other").show() : $("#other").hide();
}
</script>
let me know is this helpful?.