...

View Full Version : string elements conversion to variables



cateyes
06-02-2009, 07:15 PM
The following coding produces a set of string elements i.e.


var locate = window.location
document.order.item.value = locate

var text = document.order.item.value

text=text.replace("?","&");
text=text.replace(/[+]/g," ");
text=text.replace(/[=]/g,"&");
var str = text.split("&")

document.write(str[0]+"<br/><br/>")
document.write(str[1]+"<br/>")
document.write(str[2]+"<br/>")
document.write(str[3]+"<br/>")
document.write(str[4]+"<br/>")
document.write(str[5]+"<br/>")
document.write(str[6]+"<br/>")
document.write(str[7]+"<br/>")
document.write(str[8]+"<br/>")
document.write(str[9]+"<br/>")
document.write(str[10]+"<br/><br/>")


The result will be different depending on the order form selection, but the output is listed like this:

file:///E:/NewNetlinks/orderpass.html

Product
Diesel Supreme Ultra
SAE
15W40 CJ-4 SM
Size
330 GAL
Quantity
25
Code
127CJ3300

How do I take this list of elements and convert to variables that can be used in the following example?



function drawTable(TableID) {
var output = new Array();
var i = 0;
output[i++] = "<table id='myTable1'><tbody id='myTbody'>";
for (var j = 0; j < str.length; j++) {
output[i++] = "<tr>";
output[i++] = "<td>" + str[j][2] + "</td>";
output[i++] = "<td>" + str[j][4] + "</td>";
output[i++] = "<td>" + str[j][6] + "</td>";
output[i++] = "<td>" + str[j][8] + "</td>";
output[i++] = "<td>" + str[j][10] + "</td></tr>";
}
output[i++] = "</tbody></table>";

}


I want to be able to pass the str[] elements 2,4,6,8,10 to a table row of cells to be appended to another table.

I just can't seem to plug in the missing pieces to make this work right.

Thanks in advance.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum