CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Passing primary key from popup window

Print topic Send  topic

Author Message
durandal

Posts: 4
Posted: 01/16/2008, 8:51 PM

Here's what I am trying to do:

I have data entry page that contains a drop down listbox. I would like to be able to add new entries to the drop down listbox through a popup window that performs an insert into a reference table.

How do I pass the newly created data back to the parent window?

Thanks,

Mike
View profile  Send private message
Edd


Posts: 547
Posted: 01/18/2008, 7:50 PM

Mike,
You are going to have to use a bit of javascript to complete the task.

Step 1:
In the HTML view find the listbox and make sure it has an "id", if not add one.

Step 2:
In the calling window create a the following javascript functions in the header:
  
<script language="JavaScript1.1"><!--  
function addToList(aText, aValue) {  
    var lbObj;  
    lbObj= document.getElementById("idOfYourListBox");  
    if (lbObj) {  
        addOption(lbObj,aText,aValue);  
        sortOptions(lbObj);  
    }  
}  
  
function deleteOption(object,index) {  
    object.options[index] = null;  
}  
  
function addOption(object,text,value) {  
    var defaultSelected = false;  
    var selected = false;  
    var optionName = new Option(text, value, defaultSelected, selected)  
    object.options[object.length] = optionName;  
    object.options[object.length-1].selected = false;  
}  
  
function sortOptions(what) {  
    var copyOption = new Array();  
    for (var i=0;i<what.options.length;i++)  
        copyOption = new Array(what.value,what.text);  
  
     copyOption.sort();  
  
    for (var i=what.options.length-1;i>-1;i--)  
        what.options[index] = null;  
  
    for (var i=0;i<copyOption.length;i++)  
        addOption(what,copyOption[1],copyOption[0])  
}  
//--></script>  

Step 3:
In the popup window create a "afterinsert" event you will need to add a variation of the following:
  
Dim NewValue  
Dim NewDescription  
  
If NameOfRecordSet.Errors = 0 Then  
' As I don't know the structure of your tables I am going to leave you   
' to pull back the value of the list box and the description into   
' NewValue and NewDescription  
        unloadPage  
' The following line effectively tells the client window to update the parent window  
       response.write "<script>window.opener.addToList('" & NewDescription & "','" &  NewValue & "'); window.close();</script>"  
       response.end   
End If  

I cannot guarrantee that the code is error free as I have not debugged it - but it is generally what you need.

Hope it helps

Edd
_________________
Accepting and instigating change are life's challenges.

http://www.syntech.com.au
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.