1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

JavaScript inside <SPAN>

Discussion in 'JavaScript' started by Access, Nov 2, 2007.

  1. #1
    Hi,

    I have a group of values, basically its words and their synonyms. The “word” and it’s “synonym” have the same ID.
    I’m creating it using <SPAN> like this, so it looks like a hyperlink.

    FAST <span onclick="AddToContainer(‘1’)" style="cursor:hand;color:blue;text-decoration:underline">FAST</span>

    WHILD<span onclick="AddToContainer(‘2’)" style="cursor:hand;color:blue;text-decoration:underline">WHILD</span>

    QUICK<span onclick="AddToContainer(‘1’)" style="cursor:hand;color:blue;text-decoration:underline">QUICK</span>

    SUNNY<span onclick="AddToContainer(‘3’)" style="cursor:hand;color:blue;text-decoration:underline">SUNNY</span>

    PERFECT<span onclick="AddToContainer(‘4’)" style="cursor:hand;color:blue;text-decoration:underline">PERFECT</span>

    BRIGHT<span onclick="AddToContainer(‘3’)" style="cursor:hand;color:blue;text-decoration:underline">BRIGHT</span>



    I also have a SPAN called spContainer: <span id="spContainer" runat="server" />

    What I need to do is upon clicking on each word add it to span container.
    I also need to make it disable(not clickable) together with it’s synonym(s).
    For example I click on FAST making it disabled, and at the same time make it’s synonym QUICK also disabled.

    I need some help with JavaScript function AddToContainer.

    Thank you
     
    Access, Nov 2, 2007 IP
  2. -NB-

    -NB- Peon

    Messages:
    153
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    First of all, it's
    cursor: pointer;
    Code (markup):
    .
     
    -NB-, Nov 2, 2007 IP
  3. Access

    Access Member

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    What are you talking about?
     
    Access, Nov 2, 2007 IP
  4. KatieK

    KatieK Active Member

    Messages:
    116
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    58
    #4
    "hand" is not valid for "cursor"; you probably want to use "pointer". Ex:

    style="cursor: pointer;"
    Code (markup):
    Check out a pointer reference for all the valid properties.

    Also, I'm concerned that you say that

    An id should be unique within a page. Having multiple IDs within a page can break the DOM, and cause all kinds of issue with JavaScript.

    I'm not familiar with AddToContainer as a JavaScript function. Native JavaScript functions generally start with a lower case letter (getElementById). What library is AddToContainer a part of?
     
    KatieK, Nov 3, 2007 IP