Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2003
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question function problem

    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

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That means there's an error in your code for answer2() that returns "undefined" instead of the expected value. Can we see answer2()?
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    New Coder
    Join Date
    Apr 2003
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •