SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
Thread: passing arguments to a function
-
Jul 21, 2001, 19:33 #1
- Join Date
- Jul 2001
- Location
- atlanta ga
- Posts
- 122
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
passing arguments to a function
ive been fooling with this for a little while now. how do you pass an argument to a function.
this is the function in the head:
<script language="javascript">
function jinky(){
some.style.display='inline'}
</script>
this is the call:
<div onClick="jinky()"></div>
now this makes the div 'some' which did have a display of 'none' now become visible. which is fine. however i have several i want to do this with. why doesnt this function work:
<script language="javascript">
function jinky(txt){
txt.style.display='inline'}
</script>
this is the call:
<div onClick="jinky('some')"></div>
when i use this i get an error message. in short i guess in short how do you pass an argument to a function.
thx,
Greg
------------------
'yall sell biscuits in here'--slingblade
-
Jul 21, 2001, 21:45 #2
- Join Date
- Oct 2000
- Location
- Nashvegas Baby!
- Posts
- 7,845
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You have to tell the function what to expect. For example, if you want to use a function that opens a popup window. You want to be able to define the window size and URL string each time you call the function so you do this:
function OpenWindow(width,height,URL)
Then, when you call the function, you would do this:
javascript: OpenWindow('100','100','somepage.html')
That's the way it works. The best way to learn is to look at someone elses function and figure it out.Adobe Certified Coldfusion MX 7 Developer
Adobe Certified Advanced Coldfusion MX Developer
My Blog (new) | My Family | My Freelance | My Recipes
-
Jul 22, 2001, 07:57 #3
- Join Date
- Jul 1999
- Location
- SC, USA
- Posts
- 390
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hey Greg,
I think you'd probably be better off reading this DHTML tutorial. This way, your code will be cross-browser. Here's the link:
http://www.pageresource.com/dhtml/ryan/
However, what you can use that should work is:
<script language="javascript">
function jinky(txt){
txt.style.display='inline'}
</script>
this is the call:
<div onClick="jinky(some)"></div>
aDogModerator at www.javascriptcity.com/forums/
-
Jul 22, 2001, 13:02 #4
- Join Date
- Jul 2001
- Location
- atlanta ga
- Posts
- 122
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
adog thanx man it works now. ill cross browser it later.
oscar de la renta,
Greg
=================
'yall sell biscuits in here'--slingblade
Bookmarks