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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.