473,786 Members | 2,765 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error : undefined function

Greetings,

I have defined functions using instructions found in O'Reilly's
"JavaScript : The Definitive Guide 4th Edition." When I call on the
functions I get this type of error message.

Error: test is not defined

There is a second error message that only shows with up with some calls
to test(). Since the left-hand operand is an object property I don't
know what I'm doing wrong here.

Error: invalid assignment left-hand side
Source Code:
document.uf-s.shipping.valu e = 0;

<script language="JavaS cript">
function test(){
alert('Function call succeeded');
document.uf-s.shipping.valu e = 0;
}
</script>

<form name="uf-s" onsubmit="retur n test();">
<input type="hidden" name="shipping" value="19.00">
<input type="submit">
</form>
Thank you to everyone who can help with this problem.

Mountain Man

Nov 23 '05 #1
8 4960
de****@benhubbe ll.com wrote:
Error: invalid assignment left-hand side
Source Code:
document.uf-s.shipping.valu e = 0; ^
The minus character (`-') is, well, the minus operator
(outside of literals, as here).
<script language="JavaS cript">
<script type="text/javascript">
function test(){
alert('Function call succeeded');
document.uf-s.shipping.valu e = 0;
}
Proper indentation helps.
</script>

<form name="uf-s" onsubmit="retur n test();">


document.forms['uf-s'].elements['shipping'].value = 0;

And the `action' attribute value is missing for Valid HTML.

<http://validator.w3.or g/>
PointedEars
Nov 23 '05 #2
Thomas 'PointedEars' Lahn wrote:
de****@benhubbe ll.com wrote:
function test(){
alert('Function call succeeded');
document.uf-s.shipping.valu e = 0;
}
[...]
<form name="uf-s" onsubmit="retur n test();">


document.forms['uf-s'].elements['shipping'].value = 0;


Even better:

function test(f)
{
// ...
f.elements['shipping'].value = 0;
f.submit();
return false;
}

<form action="..." name="uf-s" onsubmit="retur n test(this);">

This should make sure that, if client-side script support is present,
the form is not submitted before the element's value is "0", as that
appears to be your intention.
PointedEars
Nov 23 '05 #3
Thank you for your help PointedEars. Unfortunately, I get "Error:
welcome is not defined" even with the trivial function below. And the
"action" attribute of my real world form has been set, I just
eliminated that detail from the code example for the sake of
simplicity.

<script language="JavaS cript">
function welcome(){
alert('Hello World');
}
</script>

Mountain Man

Nov 23 '05 #4
de****@benhubbe ll.com wrote:
Thank you for your help PointedEars.
You're welcome, however it would be appreciated if you posted according to
the well-established set of behavioral recommendations here, such as to
quote what you are referring to and to provide attribution for quoted
material.

<URL:http://jibbering.com/faq/faq_notes/pots1.html>
Unfortunately, I get "Error: welcome is not defined" even with the
trivial function below. And the "action" attribute of my real world
form has been set, I just eliminated that detail from the code example
for the sake of simplicity.
Then I suggest you use ellipsis (`...') to avoid comments on it. Too many
people do not know how to write Valid markup and about the ramifications of
invalid markup regarding the execution of script code that is operating on
that.
<script language="JavaS cript">
The `type' attribute is still missing, the `language' attribute is
deprecated, in Valid HTML 4.
function welcome(){
alert('Hello World');
}
This is syntactically correct JS/ECMAScript code. The error
must be somewhere else, perhaps in the calling statement.
</script>


Just to be sure: You did not include that same code in a script file,
say foo.js, and included that with

<script ... src="foo.js"></script>

in your HTML document, did you? Otherwise it would explain that error
message since markup outside of literals does not belong into a script
file.
PointedEars
Nov 23 '05 #5
On 2005-11-19, de****@benhubbe ll.com <de****@benhubb ell.com> wrote:
Thank you for your help PointedEars. Unfortunately, I get "Error:
welcome is not defined" even with the trivial function below. And the
"action" attribute of my real world form has been set, I just
eliminated that detail from the code example for the sake of
simplicity.
<script language="JavaS cript">


try <script type="text/javascript"> instead.

also what sort of hypertext are you using

HTML3.x
HTML4.x
XHTML
etc...

does it validate?

Bye.
Jasen
Nov 23 '05 #6
In article <11************ **********@f14g 2000cwb.googleg roups.com>,
de****@benhubbe ll.com says...
Greetings,

I have defined functions using instructions found in O'Reilly's
"JavaScript : The Definitive Guide 4th Edition." When I call on the
functions I get this type of error message.

Error: test is not defined

There is a second error message that only shows with up with some calls
to test(). Since the left-hand operand is an object property I don't
know what I'm doing wrong here.

Error: invalid assignment left-hand side
Source Code:
document.uf-s.shipping.valu e = 0;

<script language="JavaS cript">
function test(){
alert('Function call succeeded');
document.uf-s.shipping.valu e = 0;
}
</script>

<form name="uf-s" onsubmit="retur n test();">
<input type="hidden" name="shipping" value="19.00">
<input type="submit">
</form>
Thank you to everyone who can help with this problem.

Mountain Man


If you need to get some value, you must write that code whitout document
(examle form_name.name. value)
Nov 27 '05 #7
Marino Guerieri wrote:
de****@benhubbe ll.com says...
Error: invalid assignment left-hand side
Source Code:
document.uf-s.shipping.valu e = 0;
[...]


If you need to get some value, you must write that code whitout document
(examle form_name.name. value)


Utter nonsense. It is the operator character that causes the problem.
PointedEars
Nov 27 '05 #8
Marino Guerieri said the following on 11/27/2005 5:20 AM:
In article <11************ **********@f14g 2000cwb.googleg roups.com>,
de****@benhubbe ll.com says...
Greetings,

I have defined functions using instructions found in O'Reilly's
"JavaScript : The Definitive Guide 4th Edition." When I call on the
functions I get this type of error message.

Error: test is not defined

There is a second error message that only shows with up with some calls
to test(). Since the left-hand operand is an object property I don't
know what I'm doing wrong here.
<snip>
document.uf-s.shipping.valu e = 0;

document.forms['uf-s'].elements['shipping'].value


If you need to get some value, you must write that code whitout document
(examle form_name.name. value)


Who taught you that garbage?
Besides, your syntax is IE-only unless you are passed a reference to
form_name and in this case it isn't.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 27 '05 #9

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

Similar topics

12
3558
by: Xeon | last post by:
Hi, Is there anyway to set a custom error handler which is actually a method of a class? i.e. setting the method eh() of class foo as error handler in the snippet below. class foo { function eh() { do something } }
3
5309
by: skubik | last post by:
Anyone else have this problem compiling PHP 4.3.3 from source under Linux (I'm using Slackware 9.0)? Under PHP 4.3.2 I had no compilation problems at all, but now all of the sudden, compiling with GD support gives me the list of errors below. My ./configure is: ../configure --with-pgsql=/usr/local/pgsql --with-ssl=/usr/local/ssl --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-zlib-dir=/usr/lib
3
8274
by: Dan Finn | last post by:
OpenBSD 3.2 Apache 1.3.26 PHP 4.3.4 PHP-Nuke 6.9 getting these in the apache error log: Sun Nov 16 20:20:16 2003] PHP Notice: Undefined variable: HTTP_USER_AGENT in /htdocs/nuke/html/mainfile.php on line 16 PHP Notice: import_request_variables(): No prefix specified - possible security hazard in
2
2510
by: Lian Liming | last post by:
Hi, all I want to write my own error handler function in php by using "set_error_handler()" function. I have made a test for this function but found it did not work. My test code is as following: <?php function myerrorHandler ($errno, $errstr, $errfile, $errline, $errcontext) { switch ($errno) {
2
13125
by: RU | last post by:
Hi, I am working on a porting project to port C/C++ application from unixware C++, AT&T Standard components to g++ with STL on Linux. This application has been working properly on Unixware/C++/AT&T componets environment. I have been able to compile all modules after making necessary changes in LINUX/gcc/STL environment. We have two templates defined XList and XMap.
8
9581
by: Brian Tkatch | last post by:
Server: DB2/SUN 8.1.6 Client: DB2 Connect Personal Edition (No 11) <URL:ftp://ftp.software.ibm.com/ps/products/db2/fixes2/english-us/db2winIA32v8/fixpak/FP11_WR21365/FP11_WR21365_CONPE.exe> Uninstalled old version, installed new version, and am now trying to use the CLP. <<<<<<<<<<<< For more detailed help, refer to the Online Reference Manual.
4
3043
by: yogesh | last post by:
mysql in c++ initialize error occurs a simple program is executed in redhat9.0 , using gcc 3.2.2 compiler version ... #include <stdio.h> #include <mysql.h> #include <string.h> int main() {
3
11601
by: prakash.mirji | last post by:
Hello, I am getting below mention linker error when I tried to link my class test.C I use below command to compile test.C /usr/bin/g++ -g -fpic -fvisibility=default -D_POSIX_SOURCE -DTRACING - D__EXTENSIONS__ -D__RWCOMPILER_H__ -D_REENTRANT -D_RWCONFIG=8s - D_RWCONFIG_12d -D_RWSTDDEBUG -DRWDEBUG -o test1 test1.o -L/lib -
0
2752
by: Benjamin Grieshaber | last post by:
Hi, I´m on SuSE 9.3 with xmlrpc-c and xmlrpc-c-devel installed (ver. 0.9.10) I tried to compile php with xmlrpc support and got the following errors: ext/xmlrpc/.libs/xmlrpc-epi-php.o(.text+0x359): In function `set_zval_xmlrpc_type': /php-5.2.5/ext/xmlrpc/xmlrpc-epi-php.c:1313: undefined reference to `XMLRPC_CreateValueDateTime_ISO8601'
3
3283
by: singhPrabhat | last post by:
I have some .c and .h files in my directory. My aim is to compile the whole file. I am compiling each and every .c file by gcc -c file_name then I use gcc -o some_text file_name. I have found out that some file starts with #ifdef UNIX. But UNIX is nowhere defined in either header file(.h file) it includes not in the file itself. For the time being I am defining as #include UNIX in the file whereever required. some of the files...
0
9647
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
9496
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
10363
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9961
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
8989
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
7512
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
5397
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...
1
4066
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
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.