|
-
Mar 1st, 2001, 06:58 AM
#1
Thread Starter
Junior Member
<!--
Help!! See below. I am trying to pass a variable (option) to a function, which in this case is the id of a paragraph (i.e., "test_paragraph"). I'd like for the function then to turn off the display of the test_paragraph based on the passed variable (option). The id gets passed Ok as witnessed by the alert message. However, it will not work using the option.style.display="none"; whereas it will work if you type the actual name of the paragraph as shown in command that is not commented out (test_paragraph.style.display="none" . Is this a syntax problem? Since I'm not a javascript person, a potentially small syntax problem shuts me down. Thanks very much in advance.
KBH
-->
<SCRIPT>
function turn_paragraph_off(option)
{
alert(option)
test_paragraph.style.display="none";
// option.style.display="none";
}
</SCRIPT>
<%variable="test_paragraph"%>
<P onmouseover="turn_paragraph_off('<%=variable%>')" >
Move the mouse over this sentence make the test paragraph below turn off.
</p>
<br>
<br>
<br>
<p id=test_paragraph >
TEST TEST TEST TEST TEST TEST TEST TEST TEST
<br>
TEST TEST TEST TEST TEST TEST TEST TEST TEST
<br>
TEST TEST TEST TEST TEST TEST TEST TEST TEST
<br>
TEST TEST TEST TEST TEST TEST TEST TEST TEST
<br>
TEST TEST TEST TEST TEST TEST TEST TEST TEST
</p>
-
Mar 1st, 2001, 08:51 AM
#2
Hi, of course you can use a dirty way to do it and just create a small function for every different paragraph. But I guess you don't really wanna do that, huh? 
I have done it before, but since I'm no expert on javascript either, I forgot exactly how. I do remember you have to go through the object model to get to it, so something like:
window.document.items(option).style.display = "none";
Of course that's not the right line (I think) but that's the direction you gotta search in..
-
Mar 1st, 2001, 09:40 AM
#3
Addicted Member
try document.formname.item[option].style.display = "none";
atleast i think thats it
-
Mar 1st, 2001, 03:05 PM
#4
Frenzied Member
Code:
<HTML>
<HEAD>
<SCRIPT language=Javascript>
function turn_paragraph_off(option)
{
alert(option)
if (document.all[option].style.display=="none")
document.all[option].style.display = "";
else
document.all[option].style.display = "none";
//test_paragraph.style.display="none";
// option.style.display="none";
}
</SCRIPT>
</HEAD>
<BODY>
<%variable="test_paragraph"%>
<P onmouseover="turn_paragraph_off('<%=variable%>')" >
Move the mouse over this sentence make the test paragraph below turn off.
</p>
<br>
<br>
<br>
<p id=test_paragraph >
TEST TEST TEST TEST TEST TEST TEST TEST TEST
<br>
TEST TEST TEST TEST TEST TEST TEST TEST TEST
<br>
TEST TEST TEST TEST TEST TEST TEST TEST TEST
<br>
TEST TEST TEST TEST TEST TEST TEST TEST TEST
<br>
TEST TEST TEST TEST TEST TEST TEST TEST TEST
</p>
</BODY>
</HTML>
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Mar 1st, 2001, 03:37 PM
#5
Addicted Member
guess your not using forms doh. try changing paragraph from id to name. i have had problems with using id in the past, especially in netscape
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|