Jump to content

Dynamically changing a class with java


grggfks

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/215572-dynamically-changing-a-class-with-java/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.