Hi,

Are you trying to essentially make a custom "Select" form element? If
so...

- Maybe using the actually form "select" element would be better?

- Or, if you don't, then I think nowadays it is recommended *not* to
use the onClick="javascript:" attribute. Mootools-wise, it is also
better to put everything in a class, and initialise javascript links
by accessing the DOM. I have quickly written a small class that I
think does what you want. It should work on your HTML (with the
onClick attributes removed), with the small change that the
class="right" should now be an id="right" (or you could have both).

http://pastie.org/304942

What it does it it adds a 'click' listener to each of the links within
the "right" element. On click, it overwrites the 'text' part of the
first 'a' link with the text part of the clicked link.

I hope this helps.

Michal.


On Oct 31, 1:35 pm, semon <[EMAIL PROTECTED]> wrote:
> Hello
> I have a list that lookslike this one:
>
> <div id="menu_cdcats">
>
> <ul class="nav">
> <li><a href="?cat=1">START</a></li>
> <li><a href="?cat=2">HOME</a></li>
>
> <li class="right"><a href="#"
> onClick="javascript:show_menu('menu')">SELECT</a>
>    <ul id="menu" class="sub">
>    <li><a href="?cat=5"
> onClick="javascript:switch_label(this)">SINGLES</a></li>
>    ...
>    </ul>
> </li>
>
> <li><a href="?cat=3">START</a></li>
> <li><a href="?cat=4">HOME</a></li>
> </ul>
>
> </div>
>
> The function javascript:switch_label(this) is suppose to take tha
> value of the <a> tag and replace the value of the parent <li><ul> tag.
> i.e.
> in the example above, the code should get the value of the <a> tag,
> that is "SINGLES", and replace the value in another <a> tag that is
> 'SELECT'. So SELECT becomes SINGLES
>
> How do i achieve that. I've tied using get and set with no success. I
> don't know how to get values of a <tag> inside other tags and so on...
>
> function swith_label(txt) {
>
> }
>
> Thanks

Reply via email to