...

View Full Version : function problem



calavera
04-10-2003, 05:50 PM
Hi

I've got this bit of code:

document.write("Your answer was" +answer2())

For answer2() is simpy a function that calls a picture from the parent framset.
When run it will show the picture, then the text followed by an 'undefined' statement......

Any ideas what is casuing this ??

Thks!
Cal

beetle
04-10-2003, 06:02 PM
That means there's an error in your code for answer2() that returns "undefined" instead of the expected value. Can we see answer2()?

calavera
04-10-2003, 07:18 PM
this is function in the page.

function checkanswer1(){
if(parent.answer1 == 0){
document.write(parent.picture1)
}
else {
document.write(parent.picture2)}
}

it checks a variable in the parent and then depending on its value returns either of 2 images.

I tried document.write(checkanswer1()) and it displays the image followed by NaN......

ummm any ideas??

thks
Cal

beetle
04-10-2003, 07:24 PM
I asked for the code to answer2(), not checkanswer1()

however, if answer2() has a document.write() command as well, then you have a problem. That's indentical to doing this

document.write( "Your answer was" + document.write( someVale ) );

Which I'm sure you know is invalid.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum