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 - <tr>
-
<td colSpan="5"><strong><font face="Arial" size="2">Search Criteria:</strong></td>
-
-
<td><input type="text" name="GSearch" </font></strong></td>
-
-
<td colSpan="20">
-
<INPUT TYPE="RADIO" NAME="DB" VALUE="1" CHECKED>Suppliers
-
</p>
-
-
<INPUT TYPE="RADIO" NAME="DB" VALUE="2" >Members
-
</td>
-
-
<td>
-
<td colSpan="10"><input type="submit" name="submit" value="Submit" align="right" onClick="window.open
-
('Search Results.asp','mywindow','width=600,height=400')">
-
</td>
-
</tr>
thanks
12 2516
Add an id for your text box, then pass it with the url in the new window: - <input type="text" name="GSearch" id="GSearch">
- <input type="submit" name="submit" value="Submit" align="right" onClick="window.open
-
('Search Results.asp?Search='+document.getElementById('GSearch').value,'mywindow','width=600,height=400')">
-
Then in your searchresults page, just process the GET variable (you know how to do that in ASP, I assume).
Ive looked into this- but again i dont know. could you help me out?? Is is get function in asp or javascript???
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: - Request.QueryString("GSearch")
Another way is to use Javascript in your ASP page, which uses window.opener: - window.opener.document.getElementById('GSearch').value;
would be a reference to your text box value in the popup window.
Ive tried both and they arent working- however when i use - 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???
Use - Response.Write(Request.QueryString("Search"))
instead.
thanks that is working- but 1 small point is how would i be able to pass more than 2 variables across using - <input type="submit" name="submit" value="Submit" align="right" onClick="window.open
-
('Search Results.asp?Search='+document.getElementById('GSearch').value,'mywindow','width=600,height=600')">
Use '&'+your search value pair, e.g. - onClick="window.open
-
('SearchResults.asp?Search='+document.getElementById('GSearch').value+'&myVal='+document.getElementById('SomeVal').value,...
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- - <tr>
-
<td colSpan="5"><strong><font face="Arial" size="2">Search Criteria:</strong></td>
-
-
<td><input type="text" name="GSearch" id="GSearch"></font></strong></td>
-
-
<td colSpan="20">
-
<INPUT TYPE="RADIO" NAME="DB" VALUE="1" CHECKED>Suppliers
-
</p>
-
-
<INPUT TYPE="RADIO" NAME="DB" VALUE="2" >Members
-
</td>
-
-
-
<td>
-
<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')">
-
</td>
And on my pop-up page- this is how I am requesting this:- - dim B
-
B=Request.Form("DB")
-
-
if B=1 then
-
Response.Write("1")
-
-
else
-
Response.Write("2")
-
end if
-
-
H = (Request.QueryString("Search") & "<BR>")
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.
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:- - <table border="1" width="100%" bgColor="#3380b2" border="0" cellSpacing="2" cellPadding="2">
-
<tr>
-
<td colSpan="5"><strong><font face="Arial" size="2">Search Criteria:</strong></td>
-
-
<td><input type="text" name="GSearch" id="GSearch"></font></strong></td>
-
-
<td colSpan="20"><INPUT TYPE="RADIO" NAME="DB1" id="DB1" VALUE="1" CHECKED>Suppliers</td>
-
</p>
-
<td colSpan="20"><INPUT TYPE="RADIO" NAME="DB1" id="DB1" VALUE="2">Members</td>
-
-
-
-
<td>
-
-
<input type="submit" name="submit" value="Submit" align="right" onClick="window.open
-
('Search Results.asp?Search='+document.getElementById('GSearch').value+'&DB1='+document.getElementById('DB1').value, 'mywindow','width=600,height=600')">
-
-
</td>
And heres how i am requesting this - H = (Request.QueryString("Search"))
-
B = (Request.QueryString("DB1"))
If it also helps- ive also looked at this way of requeting my radio buttons:- - B= Request.Form("DB")
-
-
if B="1" then
-
Response.Write("1")
-
-
else
-
Response.Write("2")
-
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??
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
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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"...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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,...
| |