(simple newbie) changing a character on a html page

Discussion in 'Javascript' started by Lex, Oct 10, 2003.

  1. Lex

    Lex Guest

    Hi,

    I've got this code to make a table visible and hide it again:

    function showHideTable(theTable,theImg)
    {
    if (document.getElementById(theTable).style.display == 'none')
    {
    document.getElementById(theTable).style.display = 'block';
    }
    else
    {
    document.getElementById(theTable).style.display = 'none';
    }
    }

    Now, the link that triggers this says:

    "menu"

    I'd like to make it "menu +"

    and when the (hidden) table is shown to say: "menu -"

    But I don't have a clue as I really don't know anything about javascript.

    Does it need to be done with div and if so how?

    Thanks,

    Lex
     
    Lex, Oct 10, 2003
    #1
    1. Advertising

  2. Lex

    Lee Guest

    Lex said:

    >Now, the link that triggers this says:
    >
    >"menu"
    >
    >I'd like to make it "menu +"
    >
    >and when the (hidden) table is shown to say: "menu -"



    Here's how to toggle the text of a link or a button
    (in browsers that support innerHTML):

    <html>
    <head>
    <script type="text/javascript">
    function toggleLink(tag){
    if(tag.innerHTML=="Yes"){
    tag.innerHTML="No";
    }else{
    tag.innerHTML="Yes";
    }
    }
    function toggleButton(button){
    if(button.value=="More"){
    button.value="Less";
    }else{
    button.value="More";
    }
    }
    </script>
    <body>
    <a href="#" onclick="toggleLink(this)">Yes</a>
    <form>
    <input type="button" onclick="toggleButton(this)" value="More">
    </form>
    </body>
    </html>
     
    Lee, Oct 11, 2003
    #2
    1. Advertising

  3. Lex

    Lex Guest

    "Lee" <> wrote in message
    news:...

    > <script type="text/javascript">
    > function toggleLink(tag){
    > if(tag.innerHTML=="Yes"){
    > tag.innerHTML="No";
    > }else{
    > tag.innerHTML="Yes";
    > }
    > }
    > </script>



    > <body>
    > <a href="#" onclick="toggleLink(this)">Yes</a>
    > </body>



    Hi Lee, thanks a lot. Now, I've got the following:

    <tr class="NavRow"><td class="swath">&nbsp;&nbsp;</td>
    <td class="Nav" onMouseOver="navBar(this,1,1)"
    onMouseOut="navBar(this,0,1)"
    onClick="showHideTable('beheer');toggleLink(word);return false;"><div
    class="NavText"><a href="#" onClick="toggleLink(this);">Beheer menu
    +</a></td></tr>

    As you can see, the table cell the link is in reacts on a mouseover...

    I've tried lots of different things , for example:

    <td class="Nav" onMouseOver="navBar(this,1,1)"
    onMouseOut="navBar(this,0,1)"><div class="NavText"><a href="#"
    onClick="showHideTable('beheer');return false;toggleLink(this);">Beheer menu
    +</a></td></tr>

    with:

    function showHideTable(theTable)
    {
    if (document.getElementById(theTable).style.display == 'none')
    {
    document.getElementById(theTable).style.display = 'block';
    }
    else
    {
    document.getElementById(theTable).style.display = 'none';
    }
    }

    function toggleLink(tag)
    {
    if(tag.innerHTML=="Beheer menu +"){
    tag.innerHTML="Beheer menu -";
    }else{
    tag.innerHTML="Beheer menu +";
    }

    But whatever I try, both of them don't work when I try combining them...

    As long as it would work I'd be very happy, I'd be even happier if I could
    combine this in one function, that's neater no?

    Any ideas?

    Lex
     
    Lex, Oct 11, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Velvet
    Replies:
    9
    Views:
    14,972
    Joerg Jooss
    Jan 19, 2006
  2. raavi
    Replies:
    2
    Views:
    929
    raavi
    Mar 2, 2006
  3. cgbusch
    Replies:
    6
    Views:
    7,569
    Mike Brown
    Sep 2, 2003
  4. ardief

    newbie - HTML character codes

    ardief, Dec 13, 2006, in forum: Python
    Replies:
    3
    Views:
    299
    ardief
    Dec 13, 2006
  5. VK
    Replies:
    3
    Views:
    198
    Dr J R Stockton
    Mar 15, 2007
Loading...

Share This Page