469,272 Members | 1,464 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,272 developers. It's quick & easy.

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 5273
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Penn Markham | last post: by
12 posts views Thread by Gaurav Veda | last post: by
33 posts views Thread by Pushkar Pradhan | last post: by
21 posts views Thread by Stephen Biggs | last post: by
3 posts views Thread by chreo | last post: by
13 posts views Thread by Anthony de Almeida Lopes | last post: by
1 post views Thread by prads | last post: by
11 posts views Thread by aarklon | last post: by
21 posts views Thread by H9XLrv5oXVNvHiUI | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.