Solved

Using getElementById to update parent page without reloading

Posted on 2004-09-22
3
4,636 Views
Last Modified: 2008-02-01
Hi!

I have 2 pages Main.aspx and detail.aspx. The first page is a DIV The second page(detail.aspx) is an IFRAME.
When I click the edit button on the main page, it opens up the Iframe on the bottom.
When I update the individual record in the iframe on the bottom, should update the record on Main.aspx without reloading.

So I use getElementById() to get the values and assign them to the parent document.
The problem occurs when I want to use parent.document.getElementById()   or window.opener.document.getElementById()
here is a snippet.

<SCRIPT language ="javascript" id="UpdateMain">
            function UpdateMain() {
            for (i=0; i < document.all.length; i++)
            //storeid =stid ; customerid = custid  Detailid = checkbox.checked status
            var stid= document.getElementById('txtStoreID').value
            var custid= document.getElementById('TxtCustomerName').value
            var Detailid = document.getElementById('chkcontacted').checked

            var idSearch= window.parent.document.body.id
            //alert("My id is  : " + idSearch + " " )
                  
      //using DHTML document.getElementById Method to update Parent            
      window.parent.document.getElementById('DataGrid1__ctl[i]_IContacted').value=Detailid;
                  alert("The Current Status  For : " + stid + " " + custid + " is " +  Detailid  );
            //using url to update parent.
      //var url = 'Main.aspx?storeid=stid&Customerid=custid&DataGrid1__ctl[i]_IContacted.checked=Detailedid';
      //      location.href=url;
                  }

            </SCRIPT>

Your help is appreciated.
0
Comment
Question by:externet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:externet
ID: 12137179
There was a typo in the previous message:  'DataGrid1__ctl[i]_IContacted' should have been 'DataGrid1__ctl'+[i]+'_IContacted'.  

This block is now  //using DHTML document.getElementById Method to update Parent
             parent.document.getElementById('DataGrid1__ctl'+[i]+'_IContacted').value=document.getElementById('chkcontacted').checked;

when I click submit in the iframe, the parent is updated but the display in the div  does not refresh. Why?

             
0
 
LVL 15

Accepted Solution

by:
Thogek earned 500 total points
ID: 12191960
The above function looks very confused.  You have three distinct variables you are accessing ('txtStoreID', etc.), the first of which is under a for-statement (no braces means only the first line under the for is looped).  You then later set one of these values to an indexed control in the parent page 'DataGrid1__ctl[i]_IContacted'....  Looks very muddled.

Can you check that this is indeed the exact code that you are running (i.e., that appears in the "View Source" HTML of the page), and post exactly what *is* happening when you run it?
 
0
 

Author Comment

by:externet
ID: 12199502
Hello Thogek,
Thanks for your suggestions. I  have had a solution which is as follows:
function UpdateMaster() {
            <!--
            var stid= document.getElementById('txtStoreID').value
            var custid = document.getElementById('txtCustomerID').value
            var chkValue = document.getElementById('chkcontacted').checked
            var currentId = stid + "_" + custid
            parent.document.getElementById(currentId).children[0].checked=chkValue;
            
             }
      -->
      </script>
I had two Issues: The Datagrid control associates itself to the elementid.  So I Inserted a checkbox control within a <span> to maintain my id (stid + "_" + custid) unique and free from the datagrid control.  Every works now as expected.
The second issue as you indicated was my for- statement which you indicated from your reply.  
Again Thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question