If you use
print <<< NAME
//Stuff
NAME;
you can avoid escaping a lot of " and '
Just remember that you can't have any blank lines above or
below the print <<< NAME <-- (NO ";")
or the NAME; (YES ";")
<?
function display_shipping_form()
{
// Here we use the heredoc operator
print <<< END
<script language="javascript" type="text/javascript">
<!--
function set_ups_rate(rate)
{
document.checkout.elements['ups_rate'].value = rate;
document.checkout.elements['show_ups_rate'].value = rate;
}
function ups_winOpen(){
width= "300";
height="200";
optionString = " scrollbars=yes,status=yes,menubar=no,resizable=yes,location=no,toolbar=no,width=" + width + ",height=" + height;
var country = document.checkout.elements.ship_country.options[document.checkout.elements.ship_country.selectedIndex].value;
var zip = document.checkout.elements['ship_zipcode'].value;
var ServiceLevelCode = document.checkout.elements.ServiceLevelCode.options[document.checkout.elements.ServiceLevelCode.selectedIndex].value;
var weight = document.checkout.elements['weight'].value;
if(ServiceLevelCode ==""){
alert("Please select Shipping Service.");
document.checkout.elements.ServiceLevelCode.focus();
return false;
}
if(country ==""){
alert("Please select ship-to Country.");
document.checkout.elements.ship_country.focus();
return false;
}
if(zip == ""){
alert("Please select ship-to ZipCode.");
document.checkout.elements.ship_zipcode.focus();
return false;
}
self.name = "opener";
var es_zip = escape(zip);
var es_country = escape(country);
var es_weight = escape(weight);
var es_service = escape(ServiceLevelCode);
var action = "ups.php?zip=" + es_zip + '&country=' + es_country + '&service=' + es_service + '&weight=' + es_weight;
cartWindow = window.open(action,'cart',optionString);
return true;
}
//more html for a form
END;
}// end of PHP function
?>