473,657 Members | 2,953 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Doubt in basic javascript call

2 New Member
Hi everyone ,

I was testing the following piece of code and unable to proceed because
the click() method is not invoked for the button's onclick event.
The same function works fine in the onload of the body tag. Moreover the code doesnt work in IE,Opera,Firefo x. There are only four lines and simple HTML statements but I am unable to find a reason.Can someone
spot me the error that I have done here ?

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head><title>Test page</title>
  3. </head>
  4. <body>
  5. <form name="form1">
  6. <INPUT TYPE="button" NAME="myButton" VALUE="Press This" onClick="click()">
  7. </form>
  8. <script>
  9. function click(){
  10.     alert('Hi');
  11. }
  12. </script>
  13. </body>
  14. </html>
  15.  
Mar 31 '08 #1
2 1057
vee10
141 New Member
Hi,

Change the function name u should use the event name as the function name ie in ur case onclick event should not have the function name as click() and same rule applies for other events also

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head><title>Test page</title>
  3. </head>
  4. <body>
  5. <form name="form1">
  6. <INPUT TYPE="button" NAME="myButton" VALUE="Press This" onClick="click1()">
  7. </form>
  8. <script>
  9. function click1(){
  10.     alert('Hi');
  11. }
  12. </script>
  13. </body>
  14. </html>
  15.  


Hi everyone ,

I was testing the following piece of code and unable to proceed because
the click() method is not invoked for the button's onclick event.
The same function works fine in the onload of the body tag. Moreover the code doesnt work in IE,Opera,Firefo x. There are only four lines and simple HTML statements but I am unable to find a reason.Can someone
spot me the error that I have done here ?

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head><title>Test page</title>
  3. </head>
  4. <body>
  5. <form name="form1">
  6. <INPUT TYPE="button" NAME="myButton" VALUE="Press This" onClick="click()">
  7. </form>
  8. <script>
  9. function click(){
  10.     alert('Hi');
  11. }
  12. </script>
  13. </body>
  14. </html>
  15.  
Mar 31 '08 #2
ss0007
2 New Member
Hi vee10 , thx for your reply ....
I just thought for a moment that it could be bug in js ...
Apr 1 '08 #3

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

Similar topics

0
1392
by: mahesh | last post by:
Hi all, I have a doubt with OOAD and Dialogs. I have a Dialog Class. tkSimple.py It contains a class body as below. Now I am calling the tkSimple.py in another python program and using the default body, and everything from tkSimple.py. Now my requirement is as follows I need to popup a couple of other dialog boxes with a little difference in between each dialog and take
7
9277
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. # No warranty express or implied for the accuracy, fitness to purpose
7
1640
by: JCO | last post by:
I have several JavaScripts in a web page. Each script is in an individual file with extension .js. I want to know if it is possible to put all functions in one single page. If so, how do I call the specific script that I want to run. This is how I call an individual script: <SCRIPT LANGUAGE="JavaScript" src="valForm.js"></SCRIPT> Where valForm is a script that looks like this: function valForm()
2
1478
by: Eli | last post by:
Hi gurus, My question is about exchanging data on a basic HTML page between a JavaScript piece of code and a Java client-side <APPLET> residing on the same webpage. To demonstrate the idea of data encription at the client side to students my idea is to build a simple <FORM> on the webpage with 2 text fields and a submit button. The student fills in the text field on top and click Submit. At this moment, onsubmit() sends the text field...
17
2401
by: blueapricot416 | last post by:
This is a very basic question -- but I can't find the answer after looking for 20 minutes. If you code something like: function set_It() { setTimeout('Request_Complete("apple", -72)',5000) } and call it 50 times, will it cause problems because you are not
28
1914
by: dutche | last post by:
Hi, there is some kind of difference in these two statements? float num = 154.87; printf("There is : $0.0f",num); and float num = 154.87;
43
2380
by: Bill H | last post by:
25 years ago every computer came with some form of Basic interpreter so you could use yoru computer without having to buy more software. Is Javascript (teamed with HTML) set to become the new Basic, where anyone with a computer can start writing code without having to purchase any expensive languages? Bill H
7
1722
by: MikeB | last post by:
Hello All, I am new to ajax and wanted to start by trying something simple. I have a web form with an updatepanel and then inside the update panel I have a listbox. Then outside of the updatepanel I have a button. In my buttons click event in the cs / code behind, I have a loop that just inserts items in the listbox. My question is, once I click the button and the loop begins, how do I get it to update the listbox? Does this make since?...
3
2370
by: pavanpvss | last post by:
hi , I have written a javascript function like this. function call(frm) { var loc_name = document.frm.loca.value; //alert('<'+loc_name+'>'); //var objRegExp = /^(\s*)(\b*)/; //if(objRegExp.test(loc_name)) { //alert("got it");
6
1140
by: sheldonlg | last post by:
Simple overview: I want to call a function in a javascript duntion where the name of the called function is an argument value passed into the javascript function. Here is what I want: On the html pages: page1: onclick="A('a', 'C')" In the library:
0
8384
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8601
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7314
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5630
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1937
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.