473,513 Members | 2,409 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

function is not defined

Hi, I'm having a little trouble with a javascript function that I
can't get to work but can't find the reason why.

I have the folowing code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="es-mx">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Captura de informaci&oacute;n de iniciativas</title>
<link href="css/udp.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
margin-left: 3px;
margin-top: 3px;
}
-->
</style>
</head>
<script language="javascript" src="scripts/calendario/calendar3.js"
type="text/javascript"></script>
<script language="javascript1.5" type="text/javascript">
function creaObjetoAjax() {
var obj;
var navegador = navigator.appName;
if (navegador == "Microsoft Internet Explorer") {
obj = new ActiveXObject("Microsoft.XMLHTTP");
} else {
obj = new XMLHttpRequest();
}
return obj;
}

var http = creaObjetoAjax();

function enviaReq(accion) {
http.open('get', accion);
http.onreadystatechange = manejaRespuesta;
http.send(null);
}

function manejaRespuesta() {
if (http.readyState == 4) {
document.getElementById('divPromoventes').style.di splay =
"inline";
document.getElementById('divPromoventes').innerHTM L =
http.responseText;
}
}

function buscaPromo(id) {
var valor = 'scripts/buscaPromo.php?busca=' +
document.getElementById(id).promovente.value + '&partido=' +
document.getElementById(id).partido.options[document.getElementById(id).partido.options.select edIndex].value
+ '&id=' + id;
enviaReq(valor);
return false;
}

function resultado() {
document.forms[<?php $_GET['id'];?>.promovente.value='<?php
$row[0];?>';
document.getElementById('divPromoventes').style.di splay='none';
}
</script>
<body>
<form id="capIniciativa" method="post" action="capIniciativas2.php">
<table width="780" border="0" cellpadding="0" cellspacing="0">
<tr class="tituloDocto">
<td colspan="3" align="center">Sistema de captura de
iniciativas</td>
</tr>
..
..
..
<label>Promovente:
<input name="promovente" type="text" size="40"
autocomplete="off" onkeyup="buscaPromo('capIniciativa');" /></label>
..
..
..
</body>
</html>

The problem is I get a "buscaPromo is not defined" error in Firefox
and an "object expected" error in IE, can anyone help?

May 4 '07 #1
2 5430
NightWalker said the following on 5/4/2007 5:46 PM:
Hi, I'm having a little trouble with a javascript function that I
can't get to work but can't find the reason why.

I have the folowing code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Don't use XHTML on the web. IE doesn't have a clue what it is and that
makes it not worth the effort to server it to UA's that know what it is
- providing you don't depend on the DTD to let it know what it is.

<snip>
<script language="javascript1.5" type="text/javascript">
<shudder>

language attribute is deprecated and the text/javascript type is obsolete.
function creaObjetoAjax() {
var obj;
var navegador = navigator.appName;
if (navegador == "Microsoft Internet Explorer") {
obj = new ActiveXObject("Microsoft.XMLHTTP");
} else {
obj = new XMLHttpRequest();
That means your page won't work for me in IE7. IE7 supports new
XMLHttpRequest but I have ActiveX set to a "screw the webpage" setting
so it won't work for me in IE7. Don't use browser detection, use feature
detection.

<URL: http://jibbering.com/faq/index.html#FAQ4_26>

<snip>
function resultado() {
document.forms[<?php $_GET['id'];?>.promovente.value='<?php
$row[0];?>';
If you view source on that in the browser, you will see that there is no
] to close the [ for the forms collection. It is the first error that
the JS Console in Firefox points to. When the browser encounters that
error in parsing the page, it stops parsing scripts so your function
doesn't get defined because of that syntax error.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 5 '07 #2
hi NightWalker,
I got the same problem, with another function, but also AJAX.
Have you been able to solve it?
CU.
ledave

May 11 '07 #3

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

Similar topics

9
4936
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
12
10005
by: Gaurav Veda | last post by:
Hi ! I am a poor mortal who has become terrified of Python. It seems to have thrown all the OO concepts out of the window. Penniless, I ask a basic question : What is the difference between a...
33
47575
by: Pushkar Pradhan | last post by:
I'm using clock() to time parts of my code e.g. clk1 = clock(); /* code */ clk2 = clock(); /* calculate time in secs */ ...... clk1 = clock(); /* code */ clk2 = clock();
21
1749
by: Stephen Biggs | last post by:
Given this code: void f(void){} int main(void){return (int)f+5;} Is there anything wrong with this in terms of the standards? Is this legal C code? One compiler I'm working with compiles this...
3
4112
by: chreo | last post by:
I have user-defined function in MSSQL which returns Table (with 10 columns) (sorry for Polish names) CREATE FUNCTION PACZKI_Z_AKCJI (@AKCJA_ID int) RETURNS TABLE RETURN SELECT TOP 100...
13
2047
by: Anthony de Almeida Lopes | last post by:
Hello, I am wondering why it is not possible to have a function-like macro like the following: #define __nothread(name) do { \ #ifdef _PTHREAD_H ...
1
1577
by: prads | last post by:
Hello, I found this waitbar functioning pgm in a forum which does the same work as a matlab waitbar. However this pgm has an error and i cudnot figure it out. Can anyone pls correct it. Thanks,...
4
2152
by: prads | last post by:
Hello, this waitbar function (similar to the one in matlab) in C++ pops an error. Pls correct the error for me. Thanks, prads <code> #include <octave/oct.h> #if defined (HAVE_TERM_H) # ...
11
3541
by: aarklon | last post by:
Hi all, I have heard many discussions among my colleagues that main is a user defined function or not. arguments in favour:- 1) if it is built in function it must be defined in some header...
21
4659
by: H9XLrv5oXVNvHiUI | last post by:
Hi, I have a question about injecting friend functions within template classes. My question is specific to gcc (version 3.4.5) used in combination with mingw because this code (or at least code...
0
7391
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,...
0
7553
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...
1
7120
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
7542
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...
0
5697
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,...
1
5100
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...
0
3247
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...
0
1609
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 ...
0
466
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...

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.