View Full Version : 'Undefined' problem

03-07-2009, 03:04 PM
I'm trying to get to the bottom of a problem & have chosen to temporarily use a button to see what's happening.
The variable $revnam contains a persons name

echo('<input type="button" onclick="favoriteNumber('.$revnam.')">');

The simple javascript function looks like this;

function favoriteNumber(myArg)

and the error is;

'TonyBlair' is undefined

could it be something to do with untrimmed space?
I haven't got a clue to be honest :(

03-07-2009, 03:13 PM
Post your parsed output(html+javascript) taken from browser's view source option.

03-07-2009, 03:28 PM
Hi and thank you for your interest. I'm stumped!


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<link href="book.css" rel="stylesheet" type="text/css">
<script src="autosuggest.js" type="text/javascript"></script>
<script src="book.js" type="text/javascript"></script>
<script src="bookread.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
function BoxVal()
var bookvar;
bookvar = (document.frmone.tb.value);
<script language="javascript" type="text/javascript">
function favoriteNumber(myArg) {alert(myArg) }
<div id="nav1">
<a href="http://www.whatever.com/">sometext |</a>
<a href="http://www.whatever1.com/" target="_blank">sometext |</a>
<a href="http://www.whatever2.com/" target="_blank">sometext |</a>
<a href="http://www.whatever3.com/" target="_blank">sometext</a>
<div id="content1">
<span class="book">Enter data and then click the button</span>
<form name="frmone" action="">
<input type='text' style='font-family:verdana;width:300px;font-size:12px' id='tb' Value = "" >
<script type="text/javascript">
//XML file loading routine -

var customarray = new Array();
//code for IE
if (window.ActiveXObject)
//alert ('IE')
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
xmlDoc.async = false;
// code for Mozilla, etc.
else if (document.implementation && document.implementation.createDocument)
//alert ('FF')
var xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.async = false;
// code for other browsers
alert('Your browser cannot handle this script');
var words = xmlDoc.getElementsByTagName('title');
//loop through all "title" tags
//alert (words.length);
for (i=0; i < words.length; i++)
//add them to the array
customarray[i] = words[i].firstChild.nodeValue;
//alert (customarray[i]);
//create the auto-completion text box object
new actb('tb', customarray);
<input type="button" id="Button1" value="Read review" onclick="BoxVal()" >
<div id="txtHint"><span class="book">Reviews will appear here.</span></div>
<div id="txtHint2"><span class="book">Specific reviews will appear here.</span></div>


echo ('<table class="tablea">');
$xmlDoc = new DOMDocument();
for ($i=0; $i<=$x->length-1; $i++)

if ($x->item($i)->nodeType==1)
if ($x->item($i)->childNodes->item(0)->nodeValue == $q)

for ($i=0;$i<$cd->length;$i++)
if ($cd->item($i)->nodeType==1)
echo ('</td></tr></table><br /><table class="tableb">');
echo('<tr><td class="date">');
else echo('<tr><td class="date2">');
if($i%8==1 and $i>8)
$revnam = ($cd->item($i)->childNodes->item(0)->nodeValue);
if($i%8==1 and $i>7)
echo('&nbsp&nbsp&nbsp&nbsp<a href="javascript:getReaRevs('.$revnam.');">More from this reviewer</a>');
//the following line (button) is simply a way to find out why $revnam is undefined
echo('<input type="button" onclick="favoriteNumber('.$revnam.')">');
echo ('</table>');

03-07-2009, 03:59 PM
I have the solution;

this is the problem line;


it should be;


thank you for any interest :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum