How do I display a sting, based on which id is set as selected?
Posted
by Cam
on Stack Overflow
See other posts from Stack Overflow
or by Cam
Published on 2010-06-15T17:53:26Z
Indexed on
2010/06/15
18:12 UTC
Read the original article
Hit count: 167
I'd like to display a text string (to be positioned above ul) depending on which link is set to selected by the chgClass fuction. The ids for each display via an alert right now, but I can't seem to make them appear in "english". I know I can set up an array stating "id=text string" but when I do it seems to break the code I already have...
<script type="text/javascript">
var Lst;
function CngClass(obj){
if (typeof(obj)=='string') obj=document.getElementById(obj);
if (Lst) Lst.className='';
obj.className='selected';
Lst=obj;
alert(obj.id);
}
</script>
</head>
<body onload="CngClass('POSITION_WITHOUT_NOTIFY')">
<div class="slider">
<ul class="bar">
<li class="deny"><a onclick="CngClass(this);" id="POSITION_NOT_ALLOWED" href="#">Deny</a></li>
<li class="askDeny"><a onclick="CngClass(this);" id="NOTIFY_POSITION_IF_GRANTED" href="#">Ask Deny</a></li>
<li class="askAllow"><a onclick="CngClass(this);" id="NOTIFY_POSITION_IF_NO_RESPONSE" href="#">Ask Allow</a></li>
<li class="notify"><a onclick="CngClass(this);" id="NOTIFY_POSITION" href="#">Notfiy</a></li>
<li class="allow"><a onclick="CngClass(this);" id="POSITION_WITHOUT_NOTIFY" href="#">Allow</a></li>
</ul>
</div>
</body>
</html>
© Stack Overflow or respective owner