Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

callscript('ID',var1) -- how to?

Status
Not open for further replies.

nickdclements

Technical User
Joined
Nov 29, 2010
Messages
2
Location
US
below is an example of what i am trying to do. i would like to be able to enter variables into the javascript when calling the function:

--
Code:
--------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>javascript div slider</title>
<script type="text/javascript">

var x=50;
 
function slideDown() {
document.getElementById(' ? ').style.top=x+"px";
if(x>= ? ) {clearTimeout(timer1);}
else {x++; timer1=setTimeout(function(){slideDown()},15);} 
} 
 
</script>

</head>
<body>

<div id="red" style="position:absolute; width:50px; height:50px; top:50px; background-color:#F00;"></div>
<div id="blue" style="position:absolute; width:50px; height:50px; top:50px; left:100px; background-color:#00F;"></div>

<a href="#" onclick="slideDown('red',100);return false">red</a>
<a href="#" onclick="slideDown('blue',200);return false">blue</a>

</body>
</html>
--[code]--------------------------------------------------------

thanks for your thoughts...
 
Not sure what it is you are asking, but if you want t t pass parameters, make your function accept parameters. for instance:

Code:
function slideDown([red]idParam[/red],[blue]numParam[/blue]) {
document.getElementById(' [red]idParam[/red] ').style.top=[blue]numParam[/blue]+"px";
...


<a href="#" onclick="slideDown('red',100);return false">red</a>

You can call your parameters anything you want. Just use those names inside your function.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
that's exactly what i was looking for.

thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top