Hi, Back again
I was kindly given some code to enable me to hide/show a textarea dependant on a select list. .
I would like to also hide/show a label that goes with the text area and you'ld think I could work that out for myself, but no!
Can anyone steer me in the right direction with the code I've attempted?
Code:
<script type="text/javascript"> //<![CDATA[ function toggleSubmit(sel) { var submit = document.getElementById('submit'); var label = document.getElementById('justificationl'); var textarea = document.getElementById('justification'); submit.value = (sel.options[sel.selectedIndex].value=="yes") ? 'Submit Emergency Change' : 'Submit to Change Control'; textarea.style.display = (submit.value == 'Submit Emergency Change') ? 'block' : 'none'; } //]]> </script> </head> <body> <form id="form1" action="#" method="post"> <div> <label for="emergency">Emergency Change?: </label> <select id="emergency" name="emergency" onchange="toggleSubmit(this);"> <option label="Yes" value="yes">Yes</option> <option label="No" value="no" selected="selected">No</option> </select> <br /> <label for="justification1" name="justification1" style="display:none;">Please provide justification for emergency change </label> <textarea id="justification" name="justification" cols="38" rows="3" style="display:none;" title="Please provide justification for emergency change"></textarea> <input id="submit" name="submit" type="submit" value="Submit to Change Control" /> </div> </form> </body></html> <body>
I have highlighted the code that I added and hopefully some-one will be able to immediately spot where I've gone wrong.
Thanks in advance
|