Suntower
Posts: 225
|
| Posted: 07/14/2008, 1:42 PM |
|
Hi,
I know this is problematic, but I need to be able to 'pass' the contents of Request.ServerVariable("myvar") to a JS function.
I have a typical data entry page with a link that opens a 'pop_up_list' selection page using the 'SetOpenerValue()' technique in the examples. Works great. HOWEVER, there is one value that needs to be passed back from the SetOpenerValue() function that is a concatenation of a string from that HTML page -and- a server variable. (Basically it's the contents of whatever the user typed into the field + a 'customerid' session variable.)
So what I need is something like this...
<script language="JavaScript" type="text/javascript">
function SetOpenerValue(currentObj,formnum,descript,uofm,price,pkgqty,filnam)
{
var CID = Request.ServerVariables("GLO_CustomerID")
window.opener.document.SPECS.ImageLink1.src = CID + "/IMAGES/" + filnam;
window.opener.focus();
window.close();
}
...I know there is no such thing as a 'request.servervariables' object in the client, but is there a workaround?
Thanks!
---JC
_________________
---On a campaign for more examples and better docs! |
 |
 |
marcwolf
Posts: 361
|
| Posted: 07/15/2008, 6:32 PM |
|
Hi there JC
I sometimes have a similar situation where I need to get a Forms data formatted as a QueryString so I can pass it to another pop-up or to a AJAX validator.
I use a Javascript library called Prototype which has a Form.Serialize fnction.
This can serialise alll of the form's data into a query string.
With a server side variable - you could put a hidden field on to the form and pass the data that way.
Hope this helps..
Dave
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|
 |
 |
mentecky
Posts: 321
|
| Posted: 07/17/2008, 4:56 PM |
|
Suntower,
Replace
var CID = Request.ServerVariables("GLO_CustomerID")
with:
var CID = "{server_var}"
Then in the page Before Show place:
global $Tpl;
$Tpl->SetVar("server_var","Your value here");
Should do the trick.
Rick
_________________
http://www.ccselite.com |
 |
 |
Suntower
Posts: 225
|
| Posted: 07/18/2008, 9:44 AM |
|
Thanks,
I take it this is PHP?
Quote mentecky:
Then in the page Before Show place:
global $Tpl;
$Tpl->SetVar("server_var","Your value here");
How do I do this in ASP? I know how to create a static var (global to the page) but I don't understand $Tpl... ie. how to get the page generator to convert my ASP var into the JS value. (Did any of that make sense?)
Thanks,
---JC
_________________
---On a campaign for more examples and better docs! |
 |
 |
mentecky
Posts: 321
|
| Posted: 07/18/2008, 11:23 AM |
|
Quote Suntower:
Thanks,
I take it this is PHP?
Quote mentecky:
Then in the page Before Show place:
global $Tpl;
$Tpl->SetVar("server_var","Your value here");
How do I do this in ASP? I know how to create a static var (global to the page) but I don't understand $Tpl... ie. how to get the page generator to convert my ASP var into the JS value. (Did any of that make sense?)
Thanks,
---JC
Yes that is PHP, which I work in most of the time. I believe, but am not entirely sure, the code in ASP is something like:
HTMLTemplate.SetVar "server_var", "Your value here"
The JavaScript code would still be the same. Where I have "Your value here" you can put in any string value or a function that returns a string value.
Rick
_________________
http://www.ccselite.com |
 |
 |
Suntower
Posts: 225
|
| Posted: 07/18/2008, 1:17 PM |
|
Did I mention that you ABSOLUTELY ROCK!? 
Big Cheers for this.
---JC
Quote mentecky:
HTMLTemplate.SetVar "server_var", "Your value here"
The JavaScript code would still be the same. Where I have "Your value here" you can put in any string value or a function that returns a string value.
_________________
---On a campaign for more examples and better docs! |
 |
 |
mentecky
Posts: 321
|
| Posted: 07/18/2008, 2:31 PM |
|
JC,
No problem. Glad we could help!
Rick
_________________
http://www.ccselite.com |
 |
 |
|