(simple newbie) changing a character on a html page

L

Lex

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
 
L

Lee

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>
 
L

Lex

<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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,796
Messages
2,569,645
Members
45,362
Latest member
OrderTrimKetoBoost

Latest Threads

Top