Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > ASP Forms
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms 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 June 16th, 2003, 01:28 PM
Registered User
 
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Pass selected item in drop-list to a new window




Hi. I'd like to pass a selected item in a drop-down list to a new opened window (opened by a javascript "click here" link) .. so when the new window opens, that selected item in the form of the previous window is used to run a query on an ASP page.
This is the idea:

- Window 1 has drop list for user to select item
- after item is selected user clicks on a link
- that link opens a new window (an ASP page) which uses the item previously selected as a parameter for the query.

Any help anyone could provide would be GREATLY appreciated.

Thanx and regards everyone!

Omare
 
Old June 16th, 2003, 02:14 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to NotNowJohn
Default

first page:
Code:
function open_new_window_function()
{
    var url;
    var selItem=document.form.items.selectedIndex;
    var item_parameter_value=document.form.items.options[selItem].value;
    url="hehe.asp?item_parameter=" + item_parameter_value;
    new_window = window.open(url,'','width=600,height=600,statusbar=yes,scrollbars=no'); 
}
</script>
<form name="form" ..>
...
    <select name="items">
        <option value=1>Item 1
        <option value=2>Item 2
        ...
    </select>
    &nbsp;&nbsp;
    <a href="#" onclick="open_new_window_function()">new window</a> 
...
</form>
And on ASP page you can handle selected item's value using
Request.QueryString("item_parameter").

Regs,
NNJ

...but the Soon is eclipsed by the Moon
 
Old June 16th, 2003, 02:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

You can either use Javascript to create the link from the elements when you open the window or you can havve a javascript function in the new window that grabs the value form the parent window and then submits the new window to the ASP page with the correct value.
 
Old June 16th, 2003, 03:36 PM
Registered User
 
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I want to thank everyone for the help provided.

NNJ: -- you're the bestest!! it worked smoothly. Passing the parameter with java to the new window in such a way was exactly what I was having problems with.
So I want to sincerely thank you for your help.
My deepest respects go to you master.

Omare:D
 
Old June 17th, 2003, 06:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Omare, I'm glad you've found a solution with which you're happy. Just for info, you can do this with just HTML, you don't need any javascript.
Code:
<form action='newWindowPage.asp' method='POST' target='_blank'>
  <select name='items'>
    <option value='1'>Item 1
    <option value='2'>Item 2
    ...
  </select>
  <input type='submit'>
</form>
It seems people often forget about the HTML 'target' attribute when they want to open a new window, and instead jump straight for js (I'm not saying js shouldn't be used for this, just that there are other options).

rgds
Phil





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get selected item from listview? try.test.abc C# 1 January 4th, 2007 02:34 AM
Pass contents of drop down list to helper class snejsnej ASP.NET 1.0 and 1.1 Basics 0 April 12th, 2006 04:06 PM
problem in selecting the item from drop down list swati_joshi ASP.NET 1.0 and 1.1 Basics 1 March 27th, 2006 01:24 AM
How to get selected Item from Listbox? Iceman571 ADO.NET 1 March 25th, 2004 06:33 AM





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