473,396 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Function not defined

6
I'm including a script in my header. That script contains a function, in the body part of the html page I try to call that function. But firebug says its not defined. I've tried moving the script include even after the links.
Can someone help!?
Jul 7 '08 #1
12 1429
hsriat
1,654 Expert 1GB
This should not happen unless the function is being created on some event (which is still to be called), or you have a variable with its name same as the function's.
Jul 7 '08 #2
Nile
6
So, how can I fix it?
Jul 7 '08 #3
acoder
16,027 Expert Mod 8TB
You can start by posting your code (using code tags). It's difficult to point out a problem without seeing code.
Jul 7 '08 #4
Nile
6
My js is:
Expand|Select|Wrap|Line Numbers
  1. function expand(el){
  2. var element = el.ClassName;
  3. el = el.parentNode; el.getElementsByClassName(element+"Text").style.display="block";
  4. }
And my html:
[html]
<div class="subContainer">
<div class="blue" onClick="expand(this);">Home</div>
<div class="blueText">Hi</div>
</div>
[/html]
Jul 8 '08 #5
hsriat
1,654 Expert 1GB
getElementsByClassName is implemented recently, so only the latest versions of Firefox, Opera and Safari support it. Have a look at this page.

Perhaps this is causing the problem.
Jul 8 '08 #6
Nile
6
Again. What would I do?
Jul 8 '08 #7
hsriat
1,654 Expert 1GB
Try to utilize other DOM function to get the same results.

You may find these useful:
getElementById
getElementsByTagName
firstChild
lastChild
previousSibling
nextSibling
parentNode
Jul 8 '08 #8
Nile
6
It doesn't make a difference. Its the function thats "undefined". I've already tried your solution.
Jul 8 '08 #9
acoder
16,027 Expert Mod 8TB
You've got two more problems. ClassName should be className, and getElementsByClassName returns a list/array of elements, so you need to index the result, e.g. getElementsByClassName(...)[0].style...

Of course, for those browsers that don't support getElementsByClassName, just include a script that creates the function (there's many examples if you search).
Jul 8 '08 #10
Nile
6
It works!! THANKS!!!!!!
Jul 8 '08 #11
acoder
16,027 Expert Mod 8TB
Glad to hear it! Post back to the forum if you have anymore questions.
Jul 9 '08 #12
thats good you got it!

jose
Jul 9 '08 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
12
by: Gaurav Veda | last post by:
Hi ! I am a poor mortal who has become terrified of Python. It seems to have thrown all the OO concepts out of the window. Penniless, I ask a basic question : What is the difference between a...
33
by: Pushkar Pradhan | last post by:
I'm using clock() to time parts of my code e.g. clk1 = clock(); /* code */ clk2 = clock(); /* calculate time in secs */ ...... clk1 = clock(); /* code */ clk2 = clock();
21
by: Stephen Biggs | last post by:
Given this code: void f(void){} int main(void){return (int)f+5;} Is there anything wrong with this in terms of the standards? Is this legal C code? One compiler I'm working with compiles this...
3
by: chreo | last post by:
I have user-defined function in MSSQL which returns Table (with 10 columns) (sorry for Polish names) CREATE FUNCTION PACZKI_Z_AKCJI (@AKCJA_ID int) RETURNS TABLE RETURN SELECT TOP 100...
13
by: Anthony de Almeida Lopes | last post by:
Hello, I am wondering why it is not possible to have a function-like macro like the following: #define __nothread(name) do { \ #ifdef _PTHREAD_H ...
1
by: prads | last post by:
Hello, I found this waitbar functioning pgm in a forum which does the same work as a matlab waitbar. However this pgm has an error and i cudnot figure it out. Can anyone pls correct it. Thanks,...
4
by: prads | last post by:
Hello, this waitbar function (similar to the one in matlab) in C++ pops an error. Pls correct the error for me. Thanks, prads <code> #include <octave/oct.h> #if defined (HAVE_TERM_H) # ...
11
by: aarklon | last post by:
Hi all, I have heard many discussions among my colleagues that main is a user defined function or not. arguments in favour:- 1) if it is built in function it must be defined in some header...
21
by: H9XLrv5oXVNvHiUI | last post by:
Hi, I have a question about injecting friend functions within template classes. My question is specific to gcc (version 3.4.5) used in combination with mingw because this code (or at least code...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.