nescio said the following on 5/18/2006 7:51 AM:
hello,
i have a form with a listbox;
in this listbox people can choose between 'yes' and 'no';
if the choose 'yes' i want a new text field to appear.
if the choose 'no' nothing happens;
but how do i do this?
One of several ways. You can make that text field always be there and
make it visible/hidden based on the value of the select element.
i have looked on the internt but all i found where very complicated examples
that i did not unserstand at all.
Complicated examples of hiding/showing an element? I don't believe that.
<select onchange="hideElement('divToHide',this.value)">
<option value="visible">Yes
<option value="hidden">No
</select>
<div id="divToHide" style="visibility:visible">
<input name="myInput">
</div>
<script type="text/javascript">
function hideElement(elem,visibilityMode){
document.getElementById(elem).style.visibility = visibilityMode;
}
</script>
That is it at it's simplest. You could also use createElement and
appendChild to create the element but that can get messy in a hurry
trying to remove it.
--
Randy
comp.lang.javascript FAQ -
http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/