grggfks Posted October 10, 2010 Share Posted October 10, 2010 I know, I know. Everybody has this problem and there is a lot of examples on the net but, none of them seem to fit and I just can't get the right explanation. I'm pretty sure my .css is right. ( I'm new to web programming ). ...... ul li a { background-color: #262626; border : 1px solid #898989; color : #ffffff; display : block; font-size : 14px; font-weight : 500; margin-bottom : -1px; padding : 12px 10px; text-decoration : none; } ul li .hasvideo a { background-color: #262626; border : 1px solid #898989; color : #ffffff; display : block; font-size : 14px; font-weight : 500; margin-bottom : -1px; padding : 12px 10px; text-decoration : none; list-style:none; background: url(../images/VideoIcon.png) no-repeat right center; padding-left: 3px; } So... I want an icon to show up on the menu if their is a video associated with that link dynamically. Thus has video class. I have not programmed java in 15 years and a lot has changed. I'm not real sure about the classes I'm passing and if the switch is the best way to do this or not. but, here is the applicable portion if the java. .... function AddMenuItem(text, link, dtag) { var slug = "li_" + dtag + "_" + text.slugify(); var link = new Element("a", { 'onClick' : link, 'html' : text, 'href' : 'javascript:void(0);' }); var listitem = SetClass( text, dtag );//test and set video in group if( listitem == "") var listitem = new Element('li', { 'id' : slug }); listitem.adopt(link); $(dtag).adopt(listitem); } function SetClass( text, dtag ) { switch (text) { case "newest videos": var listitem = new Element("li", { "class" : "hasvideo" }); break case "HD videos": var listitem = new Element("li", { "class" : "hasvideo" }); break default: var listitem = ""; } $(dtag).adopt(listitem); return listitem; } function AddSpacer() { var listitem = new Element('li', { "class" : "space", "html" : " " }); $("mainmenu").adopt(listitem); } There is several more cases I will need to add to the switch but, only to states I need. hasvideo or not. Don't cut me down to bad. I'm learning. thanks for the help, grggfks Quote Link to comment https://forums.phpfreaks.com/topic/215572-dynamically-changing-a-class-with-java/ Share on other sites More sharing options...
Alex Posted October 11, 2010 Share Posted October 11, 2010 This is JavaScript, huge difference. I have moved the topic to the appropriate forum for you. Quote Link to comment https://forums.phpfreaks.com/topic/215572-dynamically-changing-a-class-with-java/#findComment-1120967 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.