p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Professional
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 19th, 2007, 01:44 AM
Registered User
 
Join Date: Apr 2007
Location: , , .
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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old April 19th, 2007, 02:13 AM
Friend of Wrox
Points: 5,604, Level: 31
Points: 5,604, Level: 31 Points: 5,604, Level: 31 Points: 5,604, Level: 31
Activity: 41%
Activity: 41% Activity: 41% Activity: 41%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,666
Thanks: 6
Thanked 9 Times in 9 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old April 19th, 2007, 09:45 AM
Registered User
 
Join Date: Apr 2007
Location: , , .
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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old April 19th, 2007, 07:14 PM
Friend of Wrox
Points: 5,604, Level: 31
Points: 5,604, Level: 31 Points: 5,604, Level: 31 Points: 5,604, Level: 31
Activity: 41%
Activity: 41% Activity: 41% Activity: 41%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,666
Thanks: 6
Thanked 9 Times in 9 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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



All times are GMT -4. The time now is 06:41 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc