Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 24th January 2009, 05:32
CMYK CMYK is offline
Junior Member
 
Join Date: Sep 2008
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default how do I tell javascript what type of data I'm passing to a function?

I have a function that goes like
Code:
function collapse(div) {
    var currentdiv = document.getElementById(div);
    currentdiv.style.zIndex = 3;
}
and code from the html document calls that function like
Code:
<a onclick="collapse('pictures')">pictures</a>
where pictures is the name of a <div> later on that had the id of pictures. Anyway, how can I tell Javascript that I'm passing a string so that the document.getELementById part will work? For example, the code will work if I write in document.getElementById("pictures");.
Reply With Quote
Sponsored Links
  #2  
Old 9th March 2009, 16:18
id10t id10t is offline
Senior Member
 
Join Date: Nov 2008
Posts: 240
Thanks: 2
Thanked 22 Times in 22 Posts
 
Default

javascript is typeless, so a variable holds whatever data of whatever type you stick into it

Change
Code:
document.getElementById(div)
to

Code:
document.getElementById($div)
Though... need the $div to references the variable created.
Reply With Quote
Reply

Bookmarks

Tags
getelementbyid, javascript

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Freebsd 6.1 support misterm Installation/Configuration 10 9th April 2009 09:29
Help with Bluetooth PAND josto HOWTO-Related Questions 1 7th August 2007 20:53
2.4.17 system needed modul8r Installation/Configuration 16 31st May 2007 14:15
SuSE Enterprise, PHP binary coming with ISPConfig does not work properly NexusTechUS Installation/Configuration 1 26th April 2007 20:03
Oh crap... Corrupted install TheMJ Installation/Configuration 4 17th February 2006 17:59


All times are GMT +2. The time now is 09:26.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.