Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 16th, 2005, 02:59 AM
kah kah is offline
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Operation is not allowed when the object is closed

Greeitngs,


When I'm trying to open a web page I get a popup message" Operation is not allowed when the object is closed".
 What i've done wrong? Please help me.thanks


Here is my code.

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Document </title>

    <XML ID="XMLLastnames" src="XML/Lastname_list.xml"></XML>
    <XML ID="XMLFirstnames" src="XML/Firstname_list.xml"></XML>
    <XML ID="XMLPlaces" src="XML/Place_list.xml"></XML>
    <XML ID="XMLDoctypes" src="XML/Doctype_list.xml"></XML>
    <XML ID="XMLKeywords" src="XML/Keyword_list.xml"></XML>
    <XML ID="XMLDocList" src="XML/Doclist.xml"></XML>


<SCRIPT LANGUAGE= "JavaScript">

var oOption
function CmbInit(pCmbObj, pXmlRecordSet, pFieldName)
{
    oOption = document.createElement("OPTION");
     pCmbObj.options.add(oOption);
    oOption.innerText = "";
    oOption.Value = "";
    pXmlRecordSet.movefirst();
    while (!pXmlRecordSet.eof)
    {
        oOption = document.createElement("OPTION");
        pCmbObj.options.add(oOption);
        oOption.innerText = pXmlRecordSet.fields(pFieldName);
        oOption.Value = pXmlRecordSet.fields(pFieldName);
        pXmlRecordSet.movenext();
    }
}

function CmbCheck(pCmbObj, pFieldName, pNotSearch)
{
    var fStr, fFind
    if(!pNotSearch==0)
        {return pNotSearch;}

    fStr = XMLDocList.recordset.fields(pFieldName).value;
    fFind = pCmbObj.item(pCmbObj.selectedIndex).innerText;

    if(!fFind.length>0) {return pNotSearch;}

    if (fStr.indexOf(fFind)==-1) {return -1; }
    else {return pNotSearch;}
}

function TextCheck(pTextObj, pFieldName, pNotSearch)
{
    var fStr, fFind
    if(!pNotSearch==0) {return pNotSearch;}

    fStr = XMLDocList.recordset.fields(pFieldName).value.toUp perCase();
    fFind = pTextObj.value.toUpperCase();

    if(!fFind.length>0) {return pNotSearch;}
    if (fStr.indexOf(fFind)==-1) {return -1; }
    else {return pNotSearch;}
}


</SCRIPT>

</head>




<body bgcolor="gainsboro">
<table width="100%" border="0">
    <tr>
        <td rowspan=2 width="38%" vAlign="top" Align="left"> <img src="image/ZP_logo_trans_small.gif"></td>

    <td width="45%" vAlign="top" Align="right"> <span lang=EN-US style='font-size:20.0pt;font-family:Tahoma'>Document
      Database</span></td>

    <td width="17%" vAlign="top"><span lang=EN-US style='font-size:9.0pt;font-family: Tahoma'>Version
      1.0</span><br>
        <span lang=EN-US style='font-size:8.0pt;font-family: Tahoma'>Created Nov 29 2002</span></td>
    </tr>
    <tr>
    <td colspan=2 vAlign="top"><span lang=EN-US
    style='font-size:7.5pt;font-family:Tahoma'>Please note that documents are
    continually being added to this database. If the version you are using is
    more than six months old, you may wish to request the latest version from <i>info@zplus.kz</i>.
    For more information and instructions see “readme.doc”.</span></td>
    </tr>
</table>

<table width="100%" border="0">
  <tr>
    <td width="56%"><button style="WIDTH: 81px; height: 24px; background-color: #CCCCCC; layer-background-color: #CCCCCC; border: 1px none #000000">
      <b>&nbsp;Title&nbsp;</b></button></td>
    <td width="44%">&nbsp;</td>
  </tr>
  <tr>
    <td width="56%" align="left"><SPAN id=Text5_Label style="WIDTH: 0.831in; HEIGHT: 0.146in; TEXT-ALIGN: right">English:</SPAN>
      <input type="text" id="txtTitleEng" style="WIDTH: 2.631in; HEIGHT: 0.187in" tabindex="1" size="60" value=""></td>
    <td width="44%"><SPAN id=DropdownList3_Label style="WIDTH: 0.865in; HEIGHT: 0.156in; TEXT-ALIGN: right">Place:</SPAN>
      <SELECT id="cmb_Place" style="WIDTH: 1.677in; HEIGHT: 0.167in" tabIndex=5></SELECT></td>
  </tr>
  <tr>
    <td width="56%"><SPAN id=Text6_Label style=" WIDTH: 0.831in; HEIGHT: 0.146in; TEXT-ALIGN: right">Russian:</SPAN>
      <input type="text" id="txtTitleRus" style="WIDTH: 2.631in; HEIGHT: 0.185in" tabindex="2" size="100" value=""></td>
    <td width="44%"><SPAN id=DropdownList4_Label style="WIDTH: 0.865in; HEIGHT: 0.146in; TEXT-ALIGN: right">Doc.
      type:</SPAN>
      <select id="cmb_DocType" style="WIDTH: 1.667in; HEIGHT: 0.167in" tabindex=6 name="select2"></select></td>
  </tr>
</table>
<table width="100%" border="0">
  <tr>
    <td width="53%"><button style="WIDTH: 81px; height: 24px; TEXT-ALIGN: center ; background-color: #CCCCCC; layer-background-color: #CCCCCC; border: 1px none #000000"><b>
      Author </b></button></td>
    <td width="47%"><SPAN id=code_Label style="WIDTH: 2in; HEIGHT: 0.156in; TEXT-ALIGN: right">Search
      Key Publications only:</SPAN>
      <input id="chk_KeyPubl" type="checkbox" name="checkbox" value="checkbox" tabindex="7"></td>
  </tr>
  <tr>
    <td width="53%"><SPAN id="Last_Label" style="WIDTH: 1.156in; HEIGHT: 0.167in; TEXT-ALIGN: right">Last
      name:</SPAN>
      <SELECT id="cmbLastname" style="WIDTH: 1.75in; HEIGHT: 0.187in" tabIndex=3></SELECT></td>
    <td width="47%"><SPAN id=code_Label style="WIDTH: 1.063in; HEIGHT: 0.156in; TEXT-ALIGN: right">Code:</SPAN>
      <input type="text" id="txtCode" style="WIDTH: 1.197in; HEIGHT: 0.183in" tabindex="8" size="22" value=""></td>
  </tr>
  <tr>
    <td width="53%"><SPAN id=First_Label style="WIDTH: 1.156in; HEIGHT: 0.167in; TEXT-ALIGN: right">First
      name:</SPAN>
      <SELECT id="cmb_firstname" style="WIDTH: 1.75in; HEIGHT: 0.187in" tabIndex=4></SELECT></td>
    <td width="47%"><SPAN id=Keyword_Label style="WIDTH: 1.063in; HEIGHT: 0.156in; TEXT-ALIGN: right">Keyword:</SPAN>
      <select id="cmb_Keyword" style="WIDTH: 2.26in; HEIGHT: 0.187in" tabindex="9" name="select"></select></td>
  </tr>
</table>
<table width="100%" border="0">
  <tr>
    <td width="21%"><button name="Find" ACCESSKEY="s" onClick="findClick()" style="WIDTH: 1.094in; HEIGHT: 0.25in; TEXT-ALIGN: center" id="Find"><b>[u]S</u>earch</b></button></td>
    <td width="79%" vAlign="bottom"><span lang=EN-US style='font-size:9.0pt'>To open document, click on link. To
save, right click on link and choose “Save Target As...”</span></td>
  </tr>
</table>


<SCRIPT>
    CmbInit(cmbLastname, XMLLastnames.recordset, "last_name");
    CmbInit(cmb_firstname, XMLFirstnames.recordset, "First_name");
    CmbInit(cmb_Place, XMLPlaces.recordset, "name");
    CmbInit(cmb_DocType, XMLDoctypes.recordset, "name");
    CmbInit(cmb_Keyword, XMLKeywords.recordset, "name");
</SCRIPT>

<SCRIPT LANGUAGE= "JavaScript">


    function findClick()
    {

        for(i=myTable.rows.length;i>2;i--)
            {myTable.deleteRow(i-1); }

        XMLDocList.recordset.movefirst();
        var vTR, vTD, vNRow, vSearch
        vNRow = 1
        var vStr, vFind

        while (!XMLDocList.recordset.eof)
        {
            vSearch = 0
            if(chk_KeyPubl.status)
                {if (XMLDocList.recordset.fields("KeyPubl").value==0)
                    {vSearch = -1;}
                }

            vSearch = CmbCheck(cmbLastname, "lastname", vSearch);
            vSearch = CmbCheck(cmb_firstname, "firstname", vSearch);
            vSearch = CmbCheck(cmb_Place, "place", vSearch);
            vSearch = CmbCheck(cmb_Keyword, "Keywords", vSearch);
            vSearch = CmbCheck(cmb_DocType, "docType", vSearch);

            vSearch = TextCheck(txtTitleEng, "title_eng", vSearch);
            vSearch = TextCheck(txtTitleRus, "title_rus", vSearch);
            vSearch = TextCheck(txtCode, "DocCode", vSearch);

            if (vSearch == 0)
            {
                vTR=myTable.insertRow();
                vTR.vAlign="top"
                vTD=vTR.insertCell();
                vTD.innerText=vNRow; vNRow++;

                vTD=vTR.insertCell();
                //vTD.innerText=XMLDocList.recordset.fields("title_e ng");

                if(XMLDocList.recordset.fields("attachment_eng1"). value.length>0)
                    {vTD.innerHTML="<p>"+XMLDocList.recordset.fields(" title_eng").value + "</p>" + "<a target=\"_blank\" href=\"" + XMLDocList.recordset.fields("attachment_eng1") + "\">Open Doc:" + XMLDocList.recordset.fields("attachment_eng1").val ue.substr(10,3) + "</a>";}
                else
                    {vTD.innerText=XMLDocList.recordset.fields("title_ eng").value;}

                vTD=vTR.insertCell();
                /*vTD.innerText=XMLDocList.recordset.fields("title_ rus");*/
                if((XMLDocList.recordset.fields("attachment_rus1") .value).length>0)
                    {vTD.innerHTML="<p>"+XMLDocList.recordset.fields(" title_rus").value +"</p>"+"<a target=\"_blank\" href=\"" + XMLDocList.recordset.fields("attachment_rus1") + "\">Open Doc:" + XMLDocList.recordset.fields("attachment_rus1").val ue.substr(10,3) + "</a>";}
                else
                    {vTD.innerText=XMLDocList.recordset.fields("title_ rus").value;}

                vTD=vTR.insertCell();
                vTD.innerHTML=XMLDocList.recordset.fields("Authors ").value;

                vTD=vTR.insertCell();
                if (XMLDocList.recordset.fields("KeyPubl").value==1)
                    {vTD.innerHTML="Key Document<br>" + XMLDocList.recordset.fields("notes").value+"&nbsp; ";}
                else
                    {vTD.innerHTML=XMLDocList.recordset.fields("notes" ).value+"&nbsp;";}

                vTD=vTR.insertCell();
                vTD.innerHTML=XMLDocList.recordset.fields("place") .value + "<br><i>"+XMLDocList.recordset.fields("docType").v alue+"</i><br>"+XMLDocList.recordset.fields("docDate").val ue;

                vTD=vTR.insertCell();
                vTD.innerHTML=XMLDocList.recordset.fields("Keyword s").value+"&nbsp;"


            }

        }


    }

</SCRIPT>

<table id="myTable" vAlign="top" width="100%" border=1" style="background-color: #D6DFED; layer-background-color: #D6DFED; border: 1px none #000000" bgcolor=#CCFFCC>
  <thead> <th width="32">No.</th>
    <th width="140">Title English</th>
    <th width="130">Title Russian</th>
    <th width="77">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;Authors&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
    <th width="55">Notes</th>
    <th width="96">Place/Type<br>/date</th>
    <th width="90">Keyword(s)</th>
  </thead>
  <tr>
  </tr>
</table>



</body>

</html>


 
Old February 16th, 2005, 04:11 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Probably because you are running code against the XML recordsets, e.g.
Code:
CmbInit(cmbLastname, XMLLastnames.recordset, "last_name");
before they have finished downloading. Either place this code in a function called by window.onload or use the "ondatasetcomplete" event of the XML object to fire the individual CmbInit function, you'll need one for each data island.
Code:
<XML ID="XMLLastnames" src="XML/Lastname_list.xml" ondatasetcomplete="CmbInit(cmbLastname, this.recordset, 'last_name');"></XML>
The problem with this approach is you also need to be sure the listbox, "cmbLastname" has rendered as well so perhaps:
Code:
function loadListboxes()
{
    CmbInit(cmbLastname, XMLLastnames.recordset, "last_name");
    CmbInit(cmb_firstname, XMLFirstnames.recordset, "First_name");
    CmbInit(cmb_Place, XMLPlaces.recordset, "name");
    CmbInit(cmb_DocType, XMLDoctypes.recordset, "name");
    CmbInit(cmb_Keyword, XMLKeywords.recordset, "name");
}
<body onload="loadListboxes();">
would be better.

--

Joe (Microsoft MVP - XML)
 
Old February 16th, 2005, 07:20 AM
kah kah is offline
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Joe--
Thanks for your help.
It works and i'm happy





Similar Threads
Thread Thread Starter Forum Replies Last Post
Operation is not allowed when obejct is closed zazo XSLT 19 July 25th, 2008 01:26 PM
Operation is not allowed when the object is closed lightmaker Classic ASP Basics 1 June 6th, 2008 12:29 PM
Operation is not allowed when the object is closed kingroon Classic ASP Databases 2 February 5th, 2008 10:29 AM
"OPERATION NOT ALLOWED AFTERRESULT SET IS CLOSED" picky JSP Basics 3 October 12th, 2006 03:26 PM
operation is not allowed when object is closed shoakat Classic ASP Databases 1 November 26th, 2004 12:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.