Click to See Complete Forum and Search --> : Results with & Dont Show Up


james64
02-06-2008, 02:34 PM
Hi everyone. I just stumbled into this forum and hopefully someone will be able to help me out with my dilemma ;) .

I have this code that I modified from http://javascript.internet.com/forms/confirm-order-thanks.html which allows me to take the results that have been checked on one page and confirms those results on another page (a demo of what I mean can be found at: http://javascript.internet.com/forms/confirm-order.html).

Here is my version of the code (confirmation.php):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<link rel="stylesheet" type="text/css" href="_styles.css">
<head>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function decodeString() {
valNum = new Array();
valData = new Array();
var string, length, dataCount, orderData;
string = "" + unescape(location.search);
string = string.substring(1,string.length);
length = location.search.length;
orderData = "";
dataCount = 1;
for (var c = 0; c < string.length; c++)
if (string.charAt(c).indexOf("&") != -1) dataCount++;

orderData = "<table border=0 width=85%>";
orderData += "<tr bgcolor=\"#FFFFFF\"><td><b>Type:</b></td><td><b>Name:</b></td><td><b>City:</b></td><td><b>State:</b></td><td><b>Zip:</b></td><td><b>Contact:</b></td></tr>";

for (var i = 0; i < dataCount; i++)
{
valNum[i] = string.substring(0,string.indexOf("="));
string = string.substring(string.indexOf("=")+1,string.length);
if (i == dataCount-1) valData[i] = string;
else valData[i] = string.substring(0,string.indexOf("&"));
vpipe = valData[i].indexOf("¦");
slashzero = valData[i].indexOf("Ø");
doubleS = valData[i].indexOf("§");
doubledot = valData[i].indexOf("¨");
plusminus = valData[i].indexOf("±");
lftdubarrow = valData[i].indexOf("«");
rghtdubarrow = valData[i].indexOf("»");
rsType = string.substring(0,slashzero);
rsName = string.substring(slashzero+1,doubleS);
rsCity = string.substring(doubleS+1,doubledot);
rsState = string.substring(doubledot+1,plusminus);
rsZip = string.substring(plusminus+1,lftdubarrow);
rsContact = string.substring(lftdubarrow+1,rghtdubarrow);

string = string.substring(vpipe+1,string.length);

rsName = rsName.replace(/\+/g, " ");
rsCity = rsCity.replace(/\+/g, " ");
rsState = rsState.replace(/\+/g, " ");
rsZip = rsZip.replace(/\+/g, " ");
rsContact = rsContact.replace(/\+/g, " ");

if (i % 2)
{
orderData += "<tr bgcolor=\"#FFFFFF\">";
}
else
{
orderData += "<tr bgcolor=\"#E9ECEF\">"
}
orderData += "<input type=hidden name=item" + (i+1) + "dsc value='" + rsType + "'>";
orderData += "<input type=hidden name=item" + (i+1) + "dsc value='" + rsName + "'>";
orderData += "<input type=hidden name=item" + (i+1) + "dsc value='" + rsCity + "'>";
orderData += "<input type=hidden name=item" + (i+1) + "dsc value='" + rsState + "'>";
orderData += "<input type=hidden name=item" + (i+1) + "dsc value='" + rsZip + "'>";
orderData += "<input type=hidden name=item" + (i+1) + "dsc value='" + rsContact + "'>";
orderData += "<td>" + rsType + "</td>";
orderData += "<td>" + rsName + "</td>";
orderData += "<td>" + rsCity + "</td>";
orderData += "<td>" + rsState + "</td>";
orderData += "<td>" + rsZip + "</td>";
orderData += "<td>" + rsContact + "</td>";
orderData += "</tr>";
}

orderData += "<tr bgcolor=\"#FFFFFF\">";
orderData += "<td colspan=6 align=center><a href='javascript:history.go(-1)'>Go Back</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="index.html"> Home</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:printWindow()'>Print This Page</a></td>";
orderData += "</tr>";
orderData += "</table>";
document.write(orderData);
}

// End -->
</script>

<script>
function printWindow(){
bV = parseInt(navigator.appVersion)
if (bV >= 4) window.print()
}


</script>

</head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>


<body>

<center>
<script language="JavaScript">
<!-- Begin
decodeString();
// End -->
</script>
</center>
</form>

</body>
</html>
For the most part, it is working perfectly. There is only one problem with it... any result that has an & in it will not show on this confirmation page. I also tried changing the method on my results page from GET to POST, but that made my confirmation.php page not work at all.

I have been trying to figure out and research this issue for hours, but no luck. I am hoping someone will provide me with the miracle fix here :p . Any help is greatly appreciated and thanks in advance.

James

Dragonkai
02-07-2008, 06:51 AM
You got the wrong forum, You need to go to the javascript section of Webdeveloper.

james64
02-07-2008, 11:19 AM
My bad... just posted it to the javascript section. Thanks.