473,765 Members | 2,047 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 5367
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
4340
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
12606
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 function. Thanks.
1
2189
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
3394
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
2567
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 datagrid.
14
2781
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 closewin(){
5
2464
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 detailed below - Which rund with out error, but the final function never gets called. Any help/suggestions...
3
1965
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*))' .......</div> <div id='field_2' onclick='divclick(this, *(field1 specific data*))'
5
7853
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 can put into simple terms what is needed & general principles I would be really grateful.
0
9568
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
9404
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10007
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...
1
9959
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9835
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
6649
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
5277
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...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2806
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.