Hello, I trying to code script who will show tip depending on what is selected, but for unknown reason it does not work... Here is code: <script> function give_tip() { var sel = document.getElementById ('select').value; var tip = ''; switch(sel){ case'First': tip = 'First is selected.'; break; case'Second': tip = 'Second is selected.'; break; case'Third': tip = 'Third is selected.'; break; } document.getElementById ('tip').value = tip; } </script> <select id="select" onchange='give_tip()'> <option>First</option><option>Second</option><option>Third</option> </select> <div id='tip' style="border:1px; width:100px; height:100px; overflow:auto;"> tip goes here... </div> Code (markup): Thanks.
O well, I figured out, the problem was in document.getElementById ('tip').value must be document.getElementById ('tip').innerHTML div does not like values =D. @BLuka, i was trying to show tip after visitor selected something from drop down list.
innerHTML is not standard. For text elements, to change the text element in it, you do: document.getElementById('tip').firstChild.data = tip;