473,403 Members | 2,071 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,403 software developers and data experts.

Calling a function

50
I am trying to click a button, call a javascript function with a variable and then parse the result. At this point it is not doing anything.

What am I doing wrong?


Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2.  
  3. function makeBread(abc) {
  4.     If (String(abc)=="1") {
  5.         alert("Bread's Done!:1");
  6.         }
  7.     If (String(abc)=="2") {
  8.         alert("Bread's Done!:2");
  9.         }
  10. }
  11. </script>
  12.  
  13. <body>        
  14. <input type="button" onClick="javascript:makeBread('1');" value="Done">    
  15. </body>
Sep 3 '08 #1
2 1055
Dormilich
8,658 Expert Mod 8TB
I would omit the String() function since datatypes are converted as you need them.

maybe you want to use switch() instead of 2 if's.

what about an event handler like addEventListener()/attachEvent()?

regards
Sep 3 '08 #2
gits
5,390 Expert Mod 4TB
1. javascript is case-sensitive and therefor:

Expand|Select|Wrap|Line Numbers
  1. If 
must be

Expand|Select|Wrap|Line Numbers
  1. if
otherwise you will get an error because the interpreter 'thinks' you are calling a custom function If() since it is not a keyword.

now it should work with the change, but:

2. the language attribute is deprecated so you should use:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
and

3. the following:

Expand|Select|Wrap|Line Numbers
  1. <input type="button" onClick="javascript:makeBread('1');" value="Done"> 
  2.  
should be:

[HTML]<input type="button" onclick="makeBread('1');" value="Done">
[/HTML]
according to the specs.

kind regards
Sep 3 '08 #3

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

Similar topics

8
by: Muthu | last post by:
I've read calling conventions to be the order(reverse or forward) in which the parameters are being read & understood by compilers. For ex. the following function. int Add(int p1, int p2, int...
6
by: jchao123 | last post by:
Dear All, I have an MDB file (Access 2000/XP) which contains generic routines I use in various apps (eg, API calls, File access classes etc). I have compiled into an MDE file which I reference...
14
by: ericellsworth | last post by:
Hi, I'm trying to use a class to pass variables back and forth from a form opened in dialog mode. I have created a class which invokes a form in its show method, like so: Public Sub Show() '...
1
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
2
by: Geler | last post by:
A theoretical question: Sorry if its a beginner question. Here is a quote from the MSDN explaning the C/C++ calling convention.. It demonstrates that the calling function is responsible to clean...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
15
by: dspfun | last post by:
Hi, Is it possible to print the function name of the calling function? For example, f1() and f2() both calls f3(), in f3() I would like to print the name of the function calling f3() which...
11
by: briankirkpatrick | last post by:
Forgive me if my post seems a little amateurish... I'm requesting assistance from some of you smart folks out there to get the managed calls write that meet the specification in the esa.h for...
16
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both...
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: 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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.