Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass ASP request.Form to JavaScript

Status
Not open for further replies.

jon24422531

Technical User
Jan 27, 2004
295
GB
Hi

I am not sure whether this is in the correct forum, but I have an ASP page with various links on it and one of these I would like to open a "floating" page using information from a form. So far I have this:
Code:
  	<SCRIPT LANGUAGE="JavaScript">
	<!--
	function showRemote() {

	self.name = "Parent_Window";
	
	var windowprops = "toolbar=0,location=0,directories=0,status=0, " +
	"menubar=0,scrollbars=0,resizable=0,width=400,height=500";

	Openwindow = window.open("CustAddressLabel.asp", "remote", windowprops); //opens remote win
	}
	-->
</SCRIPT>
.........Form....
<input type="button" value="Print Address" onClick="showRemote();">
I then open the "remote Window" (CustAddressLabel) with this in the ASP:
Code:
Company = Request.form("Company")
Add1 = Request.Form("Add1")
Add2 = Request.Form("Add2")
Add3 = Request.Form("Add3")
Add4 = Request.Form("Add4")
PostCode = Request.Form("PostCode")
.......... Fields...
<td
 style="vertical-align: top; font-weight: bold; color: rgb(204, 0, 0);">Company:<br>
        </td>
        <td style="vertical-align: top;"><b><input name="Company" type="text" value="<%=Company%>"> <br>
        </b></td>
......Etc...
But the relevant fields are empty..

How can I pass the Request.Form data across to this window? If I forget the JavaScript and just go for a normal link it works, so which bit have I screwed up?

Thanks.

Jonathan
 
pass the values to the window via querystring

Code:
Openwindow = window.open("CustAddressLabel.asp?Company=<%=request.form("company")&add1=<%=request.form("add1")..etc","remote",windowprops);

In your remote window, instead of request.form, use request.querystring




TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
vicverk

Once again, thanks. I am nearly there, but I am not sure how to handle the request.querystring, is that ASP? Or do I have to reference it in javascript. I'm not very good at javascript. (or ASP!)

I am off for a couple of days so please forgive me if I don't respond for a while.

Jonathan
 
^ it's asp

This assumes there was a postback to the current page from a page that contained a form element with the name "tbx". The value of that form element would be put into a variable called myVar.

<% myVar = request.form("tbx") %>

If the current page's url is something like:

myPage.asp?tbx=somethingHere

to grab the value of "tbx"

<% myVar = request.querystring("tbx") %>





TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
depending on the length of the data being passed you might exceed the querystring limit, since he's already using JS why not utilize window.opener.FORM.Element.value?


or even extra lazy, embed the formatting/data in the parent window, and open the window and document.write the innerHTML of a hidden DIV containing everything as u want it.

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
" I always think outside the 'box', because I'm never in the 'loop' " - DreX 2005
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top