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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing large data to ASP

Status
Not open for further replies.

uncle05

MIS
Mar 15, 2006
12
US
I have a function that takes the value from a text area in the parent window and passes it into a pop up window. The value is too large to pass into a query string. The value being passed in will be used as an ASP server variable. The pop up window will take the variable (it's a SQL query) and execute the query and display the results. How can I pass this value into the pop up?

***parent window***
<body>
<form id="formQuery">
<table>
<tr>
<td class="Data"><textarea cols="169" rows="3" id="textareaSQLQuery"></textarea></td>
</tr>
<tr>
<td><button onclick="DisplayResultsOnClick()"><u>D</u>isplay Results</button></td>
</tr>
</table>
</form>
</body>

***Function to pass string into pop up window***
function DisplayResultsOnClick() {
// Get SQL query from text area
strSQLQuery = formQuery.textareaSQLQuery.value

// Set popup window to display query results
var strFeatures = "location=no,menubar=no,resizable=yes,status=no,toolbar=no,scrollbars=no,height=675,width=970,top=20,left=25"

// Set the URL
var strURL = "display_results.asp"

// Open window
var objWindow = window.open(strURL, "", strFeatures)
}
 
How about setting target attribute in the form tag and use post method?
 
Just want to mention that it is not a good idea to allow a page to run a query that is passed in as form data. Very easy to use drop your database.
 
I'll elaborate on tsuji's answer.


***parent window***
<body>
<form id="formQuery" [!] action="display_results.asp" method="post" target="popupWindow"[/!]>
<table>
<tr>
<td class="Data"><textarea cols="169" rows="3" id="textareaSQLQuery" [!]name="textAreaName"[/!]></textarea></td>
</tr>
<tr>
<td><button onclick="DisplayResultsOnClick()"><u>D</u>isplay Results</button></td>
</tr>
</table>
</form>
</body>

***Function to pass string into pop up window***
function DisplayResultsOnClick() {
// Set popup window to display query results
var strFeatures = "location=no,menubar=no,resizable=yes,status=no,toolbar=no,scrollbars=no,height=675,width=970,top=20,left=25"

// Open window
var objWindow = window.open("", [!]"popupWindow"[/!], strFeatures)

[!]document.getElementById("formQuery").submit()[/!]
}

In your file "display_results.asp", you get the value of the textarea with the following line of code:
Code:
   var strSQLQuery = Request.Form("textAreaName")

**This might not be 100% correct, but if it's not, it's very close to getting you the desired effect. I think it should work though.

<.

 
Thanks guys, that worked! I didn't know you could set the target to "popupWindow". It's not listed in MSDN, or maybe I didn't look hard enough.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top