473,799 Members | 3,390 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

opening a new window

11 New Member
Heya all, I want to know how to pass a variable across when opening a new window using javascript.
Ive got a text field and a button-and by changing properties of the button i can get it to open up a new window- however i want to know how i can pass the text field value so it appears in my pop-up window

Heres my code- im using asp


Expand|Select|Wrap|Line Numbers
  1. <tr> 
  2. <td colSpan="5"><strong><font face="Arial" size="2">Search Criteria:</strong></td>
  3.  
  4. <td><input type="text" name="GSearch" </font></strong></td>
  5.  
  6. <td colSpan="20">
  7. <INPUT TYPE="RADIO" NAME="DB" VALUE="1" CHECKED>Suppliers
  8. </p>
  9.  
  10. <INPUT TYPE="RADIO" NAME="DB" VALUE="2" >Members 
  11. </td>
  12.  
  13. <td>
  14. <td colSpan="10"><input type="submit" name="submit" value="Submit" align="right" onClick="window.open
  15. ('Search Results.asp','mywindow','width=600,height=400')">
  16. </td>
  17. </tr>
thanks
Feb 7 '07 #1
12 2547
acoder
16,027 Recognized Expert Moderator MVP
Add an id for your text box, then pass it with the url in the new window:
Expand|Select|Wrap|Line Numbers
  1. <input type="text" name="GSearch" id="GSearch">
Expand|Select|Wrap|Line Numbers
  1. <input type="submit" name="submit" value="Submit" align="right" onClick="window.open
  2. ('Search Results.asp?Search='+document.getElementById('GSearch').value,'mywindow','width=600,height=400')">
  3.  
Then in your searchresults page, just process the GET variable (you know how to do that in ASP, I assume).
Feb 7 '07 #2
new214
11 New Member
Ive looked into this- but again i dont know. could you help me out?? Is is get function in asp or javascript???
Feb 7 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
The way I have described above, you should know ASP to deal with the variable. AFAIK, for a GET variable, you need to use the following:
Expand|Select|Wrap|Line Numbers
  1. Request.QueryString("GSearch")
Another way is to use Javascript in your ASP page, which uses window.opener:
Expand|Select|Wrap|Line Numbers
  1. window.opener.document.getElementById('GSearch').value;
would be a reference to your text box value in the popup window.
Feb 7 '07 #4
new214
11 New Member
Ive tried both and they arent working- however when i use
Expand|Select|Wrap|Line Numbers
  1. Response.Write(Request.QueryString)
it works?? But 1 problem with this is the fact that it displays Search= along with the result. Any ideas on how to get rid of this???
Feb 7 '07 #5
acoder
16,027 Recognized Expert Moderator MVP
Use
Expand|Select|Wrap|Line Numbers
  1. Response.Write(Request.QueryString("Search"))
instead.
Feb 7 '07 #6
new214
11 New Member
thanks that is working- but 1 small point is how would i be able to pass more than 2 variables across using

Expand|Select|Wrap|Line Numbers
  1. <input type="submit" name="submit" value="Submit" align="right" onClick="window.open
  2. ('Search Results.asp?Search='+document.getElementById('GSearch').value,'mywindow','width=600,height=600')">
Feb 12 '07 #7
acoder
16,027 Recognized Expert Moderator MVP
Use '&'+your search value pair, e.g.
Expand|Select|Wrap|Line Numbers
  1. onClick="window.open
  2. ('SearchResults.asp?Search='+document.getElementById('GSearch').value+'&myVal='+document.getElementById('SomeVal').value,...
Feb 12 '07 #8
new214
11 New Member
well ive tried that way and it doesnt seem to be working.
What Im actually doing is trying to pass the value of a radio buttons either 1 or 2 across- along with the text. The text works fine but not the passing of the radio- heres how my original page code looks like-

Expand|Select|Wrap|Line Numbers
  1. <tr> 
  2. <td colSpan="5"><strong><font face="Arial" size="2">Search Criteria:</strong></td>
  3.  
  4. <td><input type="text" name="GSearch" id="GSearch"></font></strong></td>
  5.  
  6. <td colSpan="20">
  7. <INPUT TYPE="RADIO" NAME="DB" VALUE="1" CHECKED>Suppliers
  8. </p>
  9.  
  10. <INPUT TYPE="RADIO" NAME="DB" VALUE="2" >Members 
  11. </td>
  12.  
  13.  
  14. <td>
  15. <input type="submit" name="submit" value="Submit" align="right" onClick="window.open ('Search Results.asp Search='+document.getElementById('GSearch').value+'&DB1='+document.getElementById('DB').value, 'mywindow','width=600,height=600')">
  16. </td>


And on my pop-up page- this is how I am requesting this:-

Expand|Select|Wrap|Line Numbers
  1. dim B
  2. B=Request.Form("DB")
  3.  
  4. if B=1 then 
  5. Response.Write("1")
  6.  
  7. else
  8. Response.Write("2")
  9. end if
  10.  
  11. H = (Request.QueryString("Search") & "<BR>")
Feb 14 '07 #9
acoder
16,027 Recognized Expert Moderator MVP
Two points:

To use getElementById, you must set an id for the radio buttons.

Secondly, you're passing parameter DB1, not DB, so in your popup, you should check for DB1.
Feb 14 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
7043
by: Dena Leiter | last post by:
I want to send people to a new page using a redirect but I want a new window to open. Is this possible? I've tried this: <meta http-equiv="refresh" content="0;url=http://search.epnet.com/direct.asp?jn=HBR&db=bch target=_blank"> but it doesn't open a new browser window. Is there a way to do this?
44
4746
by: Carlos Andr?s | last post by:
Hi everybody. I've got a problem. I'd like to avoid opening a new window when you have pressed the shift key and you click in the left button of the mouse. I've tried the next solution, in the body of the page I put the next code: <BODY onkeydown='notOpenNewWindow();'>
14
11099
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a window.open function? I would prefer not to create a separate HTML page. So far all I have is the basic var cwin = window.open('images/KJV-THANKS.gif', 'Thanks', 'width=243,height=420,'); cwin.focus();
2
1792
by: Keshav Gadia | last post by:
Hi, I am an ASP.net newbie. I am writing a user control that is made up of datagrid with one of the columns opening a new window to display some details on click of the set image. I have basically used ImageButton server control. The problem is because I have used a server control with runat="server",the parent page is posted back and even though the window opens up,the focus gets set to the parent window. What I want is,the new window...
5
2164
by: Roger Withnell | last post by:
This is a framed webpage with the navigation bar in "NavBar" and the main window in "Main". When opening a new page in "Main" from "NavBar" with: function OpenFrameWindow(src) { var NewWindow = window.open(src, "Main"); NewWindow.focus(); }
3
2138
by: Larry Bud | last post by:
Wanting to use a technology I saw for one of our apps. We have several apps that a user logs in at on the same page. The app is determined by a drop down. User credentials are checked, response.redirect to the application. The user ID is stored in a session variable which determines if the user is logged in. When the session var goes blank, the user is redirected to the login page. A header on each page checks this. Now, some...
3
2666
by: Bonzol | last post by:
Vb.Net 2003, 1.1. Web application. Hey there I have this, Response.Redirect("FileFiew.aspx") to go to a new page, but how do I open that page in a new window? So I will have 2 pages open,, the original page, and the page I opened.
1
11077
by: sandy21380 | last post by:
Hello, Is there a way of opening an Access form without opening the Access window? Right now when I open the form, the Access window is a lot bigger than the form so I have to resize the Access window so it doesn't take up my whole screen (the form is about 2" x 3"). If there is no way to open only the form without the Access window opening, is there a way to automatically set the size of the Access window and close the menu bar?\ Thanks!
1
1764
by: coolsidsin | last post by:
I have a apsx form (Form A), which on submiting does a time consuming task. So i want to open a new aspx window (Form B) in which I want do do that time consuming task and show progress to the user and while that task is being completed I want Form A to redirect to Form C. I opened form B in a new javascript window and updated the progress through ajax but Form A doesn't let me redirect to Form C unless Form B's processing is Completed. ...
0
2027
by: bbrewder | last post by:
I am struggling with some MSAccess automation issues. Basically, we have a .Net application that uses MSAccess for reporting (legacy code). We are able to launch MSAccess fine and even work with the MSAccess COM objects to run our reports (using GetObject(<MDB Path>) - see http://support.microsoft.com/default.aspx?scid=kb;en-us;317113&Product=vbNET for info on how to do this). The problem that we are running into is that if our Access...
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9543
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10029
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.