|
|
 |
| 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.
|
 |

April 19th, 2007, 01:44 AM
|
|
Registered User
|
|
Join Date: Apr 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

April 19th, 2007, 02:13 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,666
Thanks: 6
Thanked 9 Times in 9 Posts
|
|
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
|

April 19th, 2007, 09:45 AM
|
|
Registered User
|
|
Join Date: Apr 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

April 19th, 2007, 07:14 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,666
Thanks: 6
Thanked 9 Times in 9 Posts
|
|
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
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |