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 10 of 10
  1. #1
    New Coder
    Join Date
    Dec 2006
    Location
    GB
    Posts
    79
    Thanks
    3
    Thanked 1 Time in 1 Post

    iframe.src and other js error...

    I've been learning JS for about 6 months now, but for some reason I'm getting two error that I have no idea how to fix...

    http://www.jcford.karoo.net/codingforums.html

    Firstly, I have a function called resize which is called onload and onresize, but when called onload, it says that the Iframe (id="spare") has no properties, and the onresize doesn't even work.

    Secondly, the search function gets the value of the selected option in the dropdown list, and adds the text input value to the end and sets it as the iframes src.
    This does not work either.

    Please give me as much help as you can, thank you.
    Last edited by Jacka; 06-18-2007 at 02:19 PM.

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    when you set an event handler with a function you do not include ()

    = resize(); //mean you want to execute the code right now on the spot
    = resize; //means you want to store a 'reference' to this method

    so it should be:

    window.onload=resize;
    window.resize=resize;

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New Coder
    Join Date
    Dec 2006
    Location
    GB
    Posts
    79
    Thanks
    3
    Thanked 1 Time in 1 Post
    Ok, but it still doesn't work, even with that changed.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    How do you expect us to help you if your link doesn't work?
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    New Coder
    Join Date
    Dec 2006
    Location
    GB
    Posts
    79
    Thanks
    3
    Thanked 1 Time in 1 Post
    Sorry, the host is terrible, and decided that it was potentially a virus...

    When I get home I'll put it on a different server.

  • #6
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,300
    Thanks
    28
    Thanked 275 Times in 269 Posts
    Quote Originally Posted by A1ien51 View Post
    window.resize=resize;
    I believe that the above code should read window.onresize=resize. Just thought I’d point that out in case Jacka copied and pasted it.
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #7
    New Coder
    Join Date
    Dec 2006
    Location
    GB
    Posts
    79
    Thanks
    3
    Thanked 1 Time in 1 Post
    I found one of my mistakes, not putting "px" after the css width and height, but the search still doesn't work.

    If you type "javascript: search();", the search works as intended, but for some reason the onsubmit event isn't working.
    Last edited by Jacka; 06-18-2007 at 02:18 PM.

  • #8
    New Coder
    Join Date
    Dec 2006
    Location
    GB
    Posts
    79
    Thanks
    3
    Thanked 1 Time in 1 Post
    Any ideas?

  • #9
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Yes study javascript a bit more mainly the reserved words. search, and select are both reserved words in Javascript so you can't use them for function names or variables. change your form name to search1 and your select name to select1. Use this for your search function
    Code:
    function searchit(){
    document.getElementById('spare').src=document.search1.select1.options[document.search1.select1.selectedIndex].value+document.search1.searchinput.value;
    }
    You will also need to change search() in your onsubmit to searchit()
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #10
    New Coder
    Join Date
    Dec 2006
    Location
    GB
    Posts
    79
    Thanks
    3
    Thanked 1 Time in 1 Post
    Ah, thanks a lot Aero, it's very much appreciated!


  •  

    Posting Permissions

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