Re: Embedding JavaScript Function Call within String Parameter? (-|-)

  • From: "Bryan Garaventa" <bgaraventa11@xxxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Mon, 5 Nov 2007 12:38:30 -0800

Thanks, yes, I came to the same conclusion as well. I got it though. I was trying to make an example of an onClick triggered hide/show function. The following appears to work fine.


function toggleHide() {
var e = document.getElementById('DynamicSection');
if (e.style.display == 'block') {
e.style.display = 'none';
e.style.visibility = 'hidden';
} else {
e.style.display = 'block';
e.style.visibility = 'visible';
}
}


----- Original Message ----- From: "Marlon Brandão de Sousa" <splyt.lists@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Monday, November 05, 2007 3:40 AM
Subject: Re: Embedding JavaScript Function Call within String Parameter? (-|-)


you're talking about the onclick = ".." part?
if so try onclick="UnHideText();"
I think that only one statement can be passed inside these parameters.
If your question is about another different thing then please could
you explain better?
Marlon

2007/11/2, Bryan Garaventa <bgaraventa11@xxxxxxxxxxxxxx>:
Anyone have any ideas about this? How do you embed a javascript function
call within a string parameter?

For instance, I first have the link...

<a id="linkElementID" href="#" onclick="UnHideText(); return false;"> Toggle
show hidden text </a>

Then the functions
<script>
function UnHideText() {
linkElementID.onclick = 'HideText(); return false;';
// Function to show the text...
}
function HideText() {
linkElementID.onclick = 'UnHideText(); return false;';
// Function to hide the text again...
}
</script>

Each time the link element is clicked, it should reset the onclick to
trigger the appropriate function. It doesn't appear to work though, the
embedded function
call within the string doesn't look to work.

Thanks,

Bryan

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind




--
When you say "I wrote a program that crashed Windows," people just
stare at you blankly and say "Hey, I got those with the system, for
free."
Linus Torvalds
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: