473,573 Members | 2,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling external function via button's onclick event...

I have always used VBScript but now need to convert my syntax to JavaScript.
In an external file, I have a function that is called when a user clicks a
button on a login page. The function checks the format of data that has
been entered by the user and makes sure that all required fields have been
filled out. On the login page, between the <head></headtags I have the
following syntax:

<script language="javas cript" src="scripts/login.js"></script>

The syntax on the button is as follows:

<input type="button" name="cbSubmit" value="Login"
onClick="javasc ript:validateen try" tabindex="4" style="cursor:h and;">

When I load the page and click the button, I get the following error
message:

Error: 'validateentry' is undefined

I am a JavaScript newbie and already am at a loss to see what the problem
is! I have checked the obvious and can confirm that the function name and
case is correct and matches in both the JS file and the web page. I'm sure
it's something really simple, but I just can't see it!!

Can anyone help me?!

Debbie :(
Aug 15 '07 #1
2 5347
Debbie wrote:
I have always used VBScript but now need to convert my syntax to JavaScript.
Probably Microsoft JScript.
In an external file, I have a function that is called when a user clicks a
button on a login page. The function checks the format of data that has
been entered by the user and makes sure that all required fields have been
filled out. On the login page, between the <head></headtags
= within the `head' element.
I have the following syntax:

<script language="javas cript" src="scripts/login.js"></script>
Remove the deprecated `language' attribute, add the required `type'
attribute with value "text/javascript".
The syntax on the button is as follows:

<input type="button" name="cbSubmit" value="Login"
onClick="javasc ript:validateen try" tabindex="4" style="cursor:h and;">
`cb' is a prefix I reserve for CheckBoxes, `bt' for BuTtons; however, I
don't think this `input' element needs a name.

Remove `javascript:'. Replace the proprietary `hand' with the standards
compliant `pointer' value.
When I load the page and click the button, I get the following error
message:

Error: 'validateentry' is undefined
Maybe that is because of the missing `type' attribute. Another, more likely
possibility is that you have not used the same character case as in the
method declaration. J(ava)Script/ECMAScript identifiers are case-sensitive,
VBScript probably is not (as VBA is not).

Furthermore, as functions/methods are first-class objects (Function objects)
in ECMAScript implementations , and the identifier is a reference to that
object, using the identifier alone is not enough to call a function/method
as it probably is in VBScript. You have to append a (here empty) parameter
list, sometimes called "the call operator":

validateEntry()
HTH

PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Aug 15 '07 #2
Thomas 'PointedEars' Lahn said the following on 8/15/2007 2:13 PM:
Debbie wrote:
>I have always used VBScript but now need to convert my syntax to JavaScript.

Probably Microsoft JScript.
You have a vivid imagination sometimes.
>In an external file, I have a function that is called when a user clicks a
button on a login page. The function checks the format of data that has
been entered by the user and makes sure that all required fields have been
filled out. On the login page, between the <head></headtags

= within the `head' element.
Irrelevant.
>I have the following syntax:

<script language="javas cript" src="scripts/login.js"></script>

Remove the deprecated `language' attribute, add the required `type'
attribute with value "text/javascript".
And use an attribute whose only value is obsolete.
>The syntax on the button is as follows:

<input type="button" name="cbSubmit" value="Login"
onClick="javas cript:validatee ntry" tabindex="4" style="cursor:h and;">

`cb' is a prefix I reserve for CheckBoxes, `bt' for BuTtons; however, I
don't think this `input' element needs a name.
What you reserve prefixes for is irrelevant.
Remove `javascript:'. Replace the proprietary `hand' with the standards
compliant `pointer' value.
Totally irrelevant to anything about JS.
>When I load the page and click the button, I get the following error
message:

Error: 'validateentry' is undefined

Maybe that is because of the missing `type' attribute.
Monkeys ass and you know it.
Another, more likely possibility is that you have not used the same character
case as in the method declaration.
More monkeys ass and you know it.
Furthermore, as functions/methods are first-class objects (Function objects)
in ECMAScript implementations , and the identifier is a reference to that
object, using the identifier alone is not enough to call a function/method
as it probably is in VBScript. You have to append a (here empty) parameter
list, sometimes called "the call operator":

validateEntry()
And you only had to babble about irrelevant things for a few minutes
until you pointed out the problem.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4320
by: Christian Radermacher | last post by:
Hi, the following code has the mentioned behaviour: <html> <head> <script type="text/javascript"> function newA() { for (i=0;i<3;i++) { var a = window.frames.document.createElement("a");
3
12590
by: Curtis | last post by:
Sorry if this is the wrong newsgroup in which to post. We have an asp page on a webserver supporting asp pages. How can we run/call a function on this page using an onclick or other event from a control. For example, when an image is clicked or a combobox is changed. We know how to run a javascript, but would be nice to run an asp...
1
2184
by: Steven | last post by:
Hello, I have a Javascript function which will get executed only when I click a Image Button on my aspx page (code behind - C#). C# InImgBut on click function --> { RegisterStartupScript("FormSubmittedJSCode", "<script>init();</script>"); // line1
4
3383
by: Ryan Ternier | last post by:
I have a button event: Public Sub SwitchItem(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim btnTest As New Button Dim astrTest As String() btnTest = CType(sender, Button) astrTest = btnTest.ClientID.Split("_") strControlsToEdit = astrTest(2)
1
2549
by: Mphoza | last post by:
Hi! Programmers,,,,,, Scenario I have a DataGrid with the delete button, If the user delete the row I'd like to show a confirmation dialog box with two buttons(Yes,No). If the user click yes the program must call my user-defined function to delete the row from database. The problem is I do not know how to create a confirm on deletes in a...
14
2763
by: Paul | last post by:
Hi I have 2 functions in java script, one opens a second window-this works, the other is supposed to close this second window, does not seem to be working. Just wondering if anyone had any ideas. Here is the code, the functions are <script language="javascript"> function openwin(){ win_usr=window.open ("control_numinfo.aspx") } function...
5
2444
by: Simon Harris | last post by:
Hi All, I am trying to call a method in a web form, from an event fired in a user control. My user control displays a map, which has a link button to enlarge/shrink the map. When the user enlarges the map, I want to hide my navigation table etc, maximising the viewing area. I've been working on this for 5 hours now, so far I have as...
3
1955
by: phish.guy | last post by:
How do I call another event's onclick function from a button press? I have stored information dynamically created in a div onclick function that is not accessible directly by the button, but i need to call the onclick for the specific div. my code looks like this: <div id='field_1' onclick='divclick(this, *(field1 specific data*))'...
5
7845
by: Stinky Pete | last post by:
Hi (again) ;-) I'm still very much at the bottom of a steep learning curve with VB, so any and all help is always appreciated. I've found some code to generate the user names who have logged onto the file in question and from what I've been reading it will do what I need. However, what is eluding me is the "calling" it bit. If anyone...
0
7699
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8027
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7788
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8066
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...
0
6421
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...
1
5594
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...
0
5292
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...
0
3733
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1041
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...

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.