Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locate JavaScript Error!

Status
Not open for further replies.

dakoz

Programmer
Feb 2, 2002
74
Hi there... i am trying for the past week to implement a javascript inside a phpBB forum. The script works great individually but when i put it inside the forum i get errors. But Internet Explorer can't locate the exact location of the false. It just returns me Object Expected and line 625. Where line 625 has nothing to do with any scripts used! Is there a way to locate the exact line when the error occurs? (Dont SAy mozilla!! Already tried it)

the script i am using is the following.


// function to draw form based on image array
function drawform(){
// start of form html
formHTML = '<TABLE width=200 height=243 cellpadding=0 cellspacing=0 bgcolor=&quot;FFFFFF&quot;>' +
'<TR><TD height=243 align=center valign=top>' +


'<select class=&quot;form&quot; name=&quot;selbox&quot; size=&quot;1&quot; onChange=&quot;imgchange(this)&quot;>';
// create option tag for each element of image array
for(x=0; x<myimages.length; x++){
formHTML = formHTML + '<option value=&quot;' + myimages[x][1] + '&quot;>' + myimages[x][0] + ' ' + myimages[x][2];
}
//end of form html
formHTML = formHTML + '</select>';

//Add a text field here

//formHTML = formHTML + '<input type=&quot;text&quot; id=&quot;text1&quot; value=&quot;mmm' + myimages[0][1] + '&quot;>';



formHTML = formHTML + '<BR><img src=&quot;spacer.gif&quot; width=200 height=240 name=&quot;imgq&quot;><BR>';
formHTML = formHTML + '<A id=text1 href=&quot;#&quot;><img src=&quot;insert.jpg&quot; border=0></A>';

document.write(formHTML);
}


// function to change image source based on select change
function imgchange(obj){
var si = obj.selectedIndex;
var fname = myimages[si][1];
document.getElementById('imgq').src = fname ;


//Change text field here
document.getElementById('text1').href = 'javascript:emoticon(\'
\')';

}

formHTML = '</TD></TR></TABLE>'

any ideas?
 
such errors happen when u have not opene/closed bracktes, curly braces...

the problem i located was:
function drawform(){
// start of form html
formHTML = '<TABLE width=200 height=243 cellpadding=0 cellspacing=0 bgcolor=&quot;FFFFFF&quot;>' +
'<TR><TD height=243 align=center valign=top>' +


'<select class=&quot;form&quot; name=&quot;selbox&quot; size=&quot;1&quot; onChange=&quot;imgchange(this)&quot;>';
// create option tag for each element of image array
for(x=0; x<myimages.length; x++){
formHTML = formHTML + '<option value=&quot;' + myimages[x][1] + '&quot;>' + myimages[x][0] + ' ' + myimages[x][2];
}
//end of form html
formHTML = formHTML + '</select>';

//Add a text field here

//formHTML = formHTML + '<input type=&quot;text&quot; id=&quot;text1&quot; value=&quot;mmm' + myimages[0][1] + '&quot;>';



formHTML = formHTML + '<BR><img src=&quot;spacer.gif&quot; width=200 height=240 name=&quot;imgq&quot;><BR>';
formHTML = formHTML + '<A id=text1 href=&quot;#&quot;><img src=&quot;insert.jpg&quot; border=0></A>';

document.write(formHTML);
}


what is that part doing outside the function. if it is not a part of the function then what is that extra } doing there?


Known is handfull, Unknown is worldfull
 
oops made a mistake.... do u have any other functions in that page? like i said IE will throw up such a weird line only if:
1. braces are not closed.
2. function does not exist.

Known is handfull, Unknown is worldfull
 
no just these.

Probably some scripts are getting messed up with the one i am trying to insert... But how will i know which is the one doing the mess. Several scripts are beeing used besides the one i am trying to use.

I Need a line where the mess is beeing done! Is there a tool or something i can use to find out exactly where i have the problem?
 
Code:
alert(&quot;Got here fine\n---\nVariable1: &quot; + Variable1+&quot;\nVariable2: &quot;+ Variable2);

...and so on.

Move this block around, changing it as you need to report on various things.

Cheers,


[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top