PDA

View Full Version : pass variables to print friendly page


ladybugz46
09-12-2002, 05:00 PM
I am trying to create a print friendly order form for our site. The variables are set up for a system called web order - What I want it to do is pass the variables only to a popup with the static code for the order form in it. Then the order form will print without its headers and side bar navigation and still contain all the pertinent information.

I am using the below script:

First Page:

<html>
<head>
<title>Untitled</title>
<script language="JavaScript">

<!--

function getOrder() {
var order = new Array("!+ORNO!","!+TMF1!","!+TML1!","!+SHSM!");
document.input.data.value = order.join('_');
}
//--></script>
</head>

<body>
<form name="input" onSubmit="getOrder()" action="test_second_page.htm">
<input type="hidden" name="data">
<input type="submit">
</form>


</body>
</html>
-----------------------------------------------------------
Second Page (popup)


<html>
<head>
<title>Untitled</title>



<script language="JavaScript">
<!--
var orderValue = (location.search.substring(1)).split('=');
if (orderValue.length == 2) {
var order = unescape(orderValue[1]).split(',');
document.output.data.value = orderValue.join('\r\n');
}
//--></script>
</head>




<body>
<form name="output">
<textarea name="data" cols="2" rows="10"></textarea>
</form>


</body>
</html>

---------------------------------------------------
I have the following questions:
(and yes...I am really new to javascript and really really trying to learn here)
0. The above script is my test script, in the working environment, it passes the varialbles to the location bar fine....where I really don't understand is how to get it back in the page in the pop up.
1. This script errors in the second page and for the life of me I can't see why.
2. Shouldn't it print the value of the array into the text area? It does not and I don't see why. I can send the entire page and a link to the site so that you can see the entire page if that will help.
3. Ultimately I need to restore the variables in the pop up with the html from the original page. Is this a good way to approach this problem or is there a better way.
4. My supervisor would prefer that I do this in vbscript....I am new to vbscript....does anyone know of any tutorials that might help.

Thanks in advance: sue

beetle
09-12-2002, 05:34 PM
See this (http://www.codingforums.com/showthread.php?s=&postid=25792#post25792) and let me know if that helps you any. Make sure to read to the last post.

Owl
09-12-2002, 05:55 PM
Hi sue,

In the popup, replace this:<script language="JavaScript">
<!--
var orderValue = (location.search.substring(1)).split('=');
if (orderValue.length == 2) {
var order = unescape(orderValue[1]).split(',');
document.output.data.value = orderValue.join('\r\n');
}
//--></script>with this:<script language="JavaScript">
<!--
onload = function(){
var orderValue = (location.search.substring(1)).split('=');
if (orderValue.length == 2) {
var order = unescape(orderValue[1]).split('_');
document.output.data.value = order.join('\r\n');
}
}
//--></script>( •) (• )
>>V

ladybugz46
09-13-2002, 06:43 AM
Beetle, please pardon my newness here. Your post looks incredibly helpful. I will be able to try this on our live site tomorrow....I am curious about where mordred used GET.....I always thought that retrieved variables from a server...can it also retrieve values from a location bar....also the same as post...can it put values on a location bar (append to url)???

If so, it seems as tho I don't see it used very often. Is there any advantages or disadvantages to using it?

Note to owl....your suggestion looks great and I will be trying it tomorrow...will let you know. Thanks to everyone!! suez