Hello I am pretty new to javascript and was wondering how I can make a button, that gets clicked and shows/hides a table? But when the button is clicked it changes to a “-” and clicked again to a “+” back and forth. I am using a news system so for the id of the table..it would be {news-id} because it shows the id of the post when it is published. I have gotten some help before about this but it still doesn’t seem to work. The script my friend said to use for the “botton change from + to -” and to show/hide is this:
[CODE]<script type=”text/javascript”>
function change(name,was,will,first,second){ if((id = document.getElementById(name))) { if(id.value != was) { id.value = was; showmenu(first); hidemenu(second); } else { id.value = will; showmenu(second); hidemenu(first); } }}function showmenu(elmnt) { document.getElementById(elmnt).style.visibility=”visible” }function hidemenu(elmnt) { document.getElementById(elmnt).style.visibility=”hidden” }</script>
So in my page for the button I would put this:
[CODE]<input type=”button” id=”{news-id}” value=”+ Show” onclick=”change(‘{news-id}’,’+ Show’,’- Hide’,'{news-id}s’,'{news-id}h’);” />
So how could the button be the “initial thing to always show when clicked” and the table below it show and hide when clicked?? Thanks if anyone can help because that one up there didnt really work! ?