Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Highlighting one <li> after being clicking
Old 02-21-2008, 04:12 PM Highlighting one <li> after being clicking
RadGH's Avatar
Skilled Talker

Posts: 76
Name: Radley
Trades: 0
I have a list of music that I organized into a styled list and when you select one of those items it resubmits the .innerhtml flash object with the new content. I need a way to change the select ones ID to "selected" or something similar, which sounds easy.

But then I would also need to find out which ID was selected (How do you get an element's id within a function without passing something in as a parameters?).

And then I need to null the ID after another <li> is selected... Unless its done automatically since ID's are supposed to be exclusive, right?

Heres part of the list, minus the styles attached to it, with the JS I'm using, minus the flash code.

PHP Code:
<ul id="Musiclist">
   <
li> <a onclick="changeLink('cncmusic/files/in%20deep.mp3')">In Deep</a>
   <
li> <a onclick="changeLink('cncmusic/files/hell%20march.mp3')">Hell March</a>
</
ul>

    <
script type="text/javascript">
    var 
source="<object ..."
    function 
changeLink(targetsrc)
    {
        
srcc document.getElementById('player').src;
        
start srcc.search("id=");
        ...
set some variables and swap the player
    
}
    
</script> 
The code works fine right now, but the flash player I'm using doesn't show the title of the track being played for these files for some reason, so I need a way to show whats being played and would like to show that with a selection box around the <li>.
RadGH is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-21-2008, 04:19 PM Re: Highlighting one <li> after being clicking
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
You'd have to pass the ID as a parameter. In this particular case, though, you wouldn't want to pass the LI id as the innerHTML read would also include the link code.

Do something like this:
Code:
<li><a onclick="changeLink('cncmusic/files/in%20deep.mp3', 'in-deep')"><span id="in-deep">In Deep</span></a></li>
The sole purpose of the span tag is for the Javascript to read the inner HTML (i.e. the title and the title only.)
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 02-21-2008, 10:25 PM Re: Highlighting one <li> after being clicking
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
Trades: 0
You might want to use a class instead of changing element ids to highlight something.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Reply     « Reply to Highlighting one <li> after being clicking
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17496 seconds with 12 queries