www.webdeveloper.com
Results 1 to 8 of 8

Thread: Error message: Object is expected

  1. #1
    Join Date
    Mar 2004
    Posts
    7

    Error message: Object is expected

    Could anyone tell me how to solve the "object is expected" error in the code below:
    <HEAD>
    <script language=javascript type=text/javascript>

    function AmazonNextPage(NextPage)
    {
    document.write("the next page is ")
    document.write(NextPage)
    }

    function AmazonStartPage(SearchPage)
    {
    document.write("the start page is ")
    document.write(SearchPage)

    document.write("<input type='button' value='step2' onclick='javascript:AmazonNextPage(2);' />")
    }

    </script>
    </HEAD>
    <BODY>

    <input type="button" value="step1" onclick="javascript:AmazonStartPage(1);" />

    </BODY>

  2. #2
    Join Date
    Jul 2003
    Location
    Boston Area, Massachusetts
    Posts
    3,489
    Did you not just post this?

  3. #3
    Join Date
    Mar 2004
    Posts
    7
    I have analysed my previous problem and created this small simple example out of it.
    I realise that the problem is due to the document.write method, for it opens a new window in which the second function is not available. This results in the error message "object is expected". I don't think I am the fist who ever bumped into this problem.

  4. #4
    Join Date
    Jun 2003
    Location
    The United States Site: http://kellyj.t35.com
    Posts
    2,561
    When you write to the document, the 'old' stuff is gone, try writing to a span object:
    PHP Code:
    <HEAD
    <
    script language=javascript type=text/javascript

    function 
    AmazonNextPage(NextPage

    document.write("the next page is "
    document.write(NextPage


    function 
    AmazonStartPage(SearchPage

    first.innerHTML "the start page is "
    first.innerHTML += SearchPage

    first
    .innerHTML += "<input type='button' value='step2' onclick='javascript:AmazonNextPage(2);' />"


    </script> 
    </HEAD> 
    <BODY> 

    <span id="first"><input type="button" value="step1" onclick="javascript:AmazonStartPage(1);" /></span>

    </BODY> 

  5. #5
    Join Date
    Mar 2004
    Posts
    7
    I have analysed my previous problem and created this small simple example out of it.
    I realise that the problem is due to the document.write method, for it opens a new window in which the second function is not available. This results in the error message "object is expected". I don't think I am the fist who ever bumped into this problem.

  6. #6
    Join Date
    Jun 2003
    Location
    The United States Site: http://kellyj.t35.com
    Posts
    2,561
    did you happen to see my reply ... how went it?

  7. #7
    Join Date
    Mar 2004
    Posts
    7
    I saw your reply and it worked fine. Thanks!
    I am now figuring it out how I can use this best.
    Last edited by msijbers; 03-02-2004 at 06:28 PM.

  8. #8
    Join Date
    Jan 2004
    Location
    Washington DC
    Posts
    1,107

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles