Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional 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 April 19th, 2007, 12:44 AM
Registered User
 
Join Date: Apr 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Opening new window to update db info...

Hi all,
I am building an application in classic ASP/vbscript and I was wondering if anyone had any advice on how to go about doing something. I have a form with some dynamic list boxes and drop down boxes (i.e. one of them is for categories). I would like to have a button on the form to "add a new category", which would launch a new window with a form to enter a new category. I would then like the user to create and save the new category, close the window, return to the original form and update the drop down list to include the newly added category.

I'm sure I need a combination of asp and javascript, but i'm not sure how to go about this. anyone ever do this before? Anyone have any ideas or examples?

Thanks so much in advance.
--Daniela

 
Old April 19th, 2007, 01:13 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

I just happen to be doing exactly what you want at this minute

Javascript function for head of document (parent window):

    var newWindow
    function openNewWin(pageURL, pageName, width, height, top, left)
    {
         newWindow = window.open(pageURL, pageName,"width=" + width + ",height=" + height + ",top=" + top + ",left=" + left + ",scrollbars=1, resizable=1,toolbar=0,location=0,status=1,menubar= 0");
         newWindow.focus()
    }

Open new window link place in body (parent window):

<a href="#" onClick="openNewWin('pageName.asp','windowName',75 0,300,100,100);">Open Window</a>


put this code in your new window where you save the new category (child window):

if [your condition to detect inserting category] then
        sql = "INSERT INTO..."
             conn.execute(sql)
%>
<script language = JavaScript>
opener.history.go(0);
self.close();
</script>

<% end if %>


FYI: The above JS code closes the active window once the categroy is inserted and refreshes the parent window so your new category appears in your list. BTW: Yes you can place some JS in the middle of an ASP if condition

Wind is your friend
Matt
 
Old April 19th, 2007, 08:45 AM
Registered User
 
Join Date: Apr 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey Matt,
Thanks so much for your quick reply and the code! I'm gonna try it out. I have a question though. When I return to the parent window, is there any way to just refresh the list box of categories instead of the whole page? if i refresh the whole page, i assume that all of the other values on the form will get wiped out? I certainly don't want that to happen!

Thanks again for your help.

--Daniela

 
Old April 19th, 2007, 06:14 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Yes and no, it depends what your process is - difficult to tell with limited information. Why dont change the process of creating a new category:

In the category selection part of your form, you could have two options EG:

1..Choose from the available categories [Drop down list]
OR
2..Create a new category [input type text area]

When the form is submitted I would:
if trim(request.form("thenameOfYourInputTextArea")) <> "" then
   insert the new categroy
else
   insert the selected category from select list
end if

This would be one of the many ways to skin a cat.

Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening a New Window GailCG ASP.NET 2.0 Basics 14 April 1st, 2008 11:32 AM
update the window controls even if a model window( maheep83 VS.NET 2002/2003 0 August 23rd, 2006 07:28 AM
opening a new window rgpassey Javascript How-To 2 September 14th, 2005 11:38 AM
Close Parent window on opening child window pkdev Javascript How-To 8 April 11th, 2004 12:06 PM
Opening New Window james_sellwood ASP.NET 1.0 and 1.1 Basics 5 June 12th, 2003 11:43 AM





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