473,387 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

opening a new window

11
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 2516
acoder
16,027 Expert Mod 8TB
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
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 Expert Mod 8TB
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
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 Expert Mod 8TB
Use
Expand|Select|Wrap|Line Numbers
  1. Response.Write(Request.QueryString("Search"))
instead.
Feb 7 '07 #6
new214
11
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 Expert Mod 8TB
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
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 Expert Mod 8TB
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
new214
11
there is abit of a problem, ive done what u said- however- when im selecting either radio button it only send the value 1. Whether i select the first radio button or the second it only passed the value 1???

Heres my input button code:-

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


And heres how i am requesting this

Expand|Select|Wrap|Line Numbers
  1. H = (Request.QueryString("Search"))
  2. B = (Request.QueryString("DB1"))
If it also helps- ive also looked at this way of requeting my radio buttons:-

Expand|Select|Wrap|Line Numbers
  1. B= Request.Form("DB")
  2.  
  3. if B="1" then 
  4. Response.Write("1")
  5.  
  6. else
  7. Response.Write("2")
  8. end if
However it Is not working- this time it only prints out 2 even though ive selected the first radio button- the the exact opposite of the first problem- not sure why?

Any suggestions??
Feb 14 '07 #11
new214
11
Ive got it sorted - thanks to all- all i did was create a script and feed all the information to the script so that it opens the link from the script which enabled me to send the info to the next page
Feb 14 '07 #12
acoder
16,027 Expert Mod 8TB
Ive got it sorted - thanks to all- all i did was create a script and feed all the information to the script so that it opens the link from the script which enabled me to send the info to the next page
Glad you got it sorted. I was about to suggest that you set the target of your form to the new open window and let the GET method pass the values automatically, but you got it working anyway. The Javascript method of getting the selected value from a radio button requires looping through the radio buttons.
Feb 14 '07 #13

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

Similar topics

2
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"...
44
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...
14
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...
2
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...
5
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...
3
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,...
3
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...
1
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...
1
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.