Iterrate Http Request Problem
I am trying to Iterrate through each row on the grid and then using AW.HTTP.Request create a dump file of the grid.
The code below works and creates a file, however it's not in same sort order as the grid, why????
Heres the code that creates the file,
Here's the example HTTPResponse.php
Here is the example file it creates
As you can see the order of the lines is not the same as the grid...
Please advice
The code below works and creates a file, however it's not in same sort order as the grid, why????
Heres the code that creates the file,
<script>
var myCells = [
["MSFT","Microsoft Corporation", "314,571.156", "32,187.000", "55000"],
["ORCL", "Oracle Corporation", "62,615.266", "9,519.000", "40650"],
["SAP", "SAP AG (ADR)", "40,986.328", "8,296.420", "28961"] ,
["MSFT","Microsoft Corporation", "314,571.156", "32,187.000", "55000"],
["ORCL", "Oracle Corporation", "62,615.266", "9,519.000", "40650"],
["SAP", "SAP AG (ADR)", "40,986.328", "8,296.420", "28961"] ,
];
var myHeaders = [
"Ticker", "Company Name", "Market Cap.", "$ Sales", "Employees"
];
var obj = new AW.UI.Grid;
obj.setSelectionMode("multi-row");
obj.setSize(760, 280);
obj.setCellText(myCells);
obj.setHeaderText(myHeaders);
obj.setColumnCount(5);
obj.setRowCount(10);
obj.setCellEditable(true);
var print = new AW.UI.Button;
print.setStyle("width","100px");
print.setControlText("Print Report");
print.onControlClicked = function printReport() {
for(var i=0;i<obj.getRowCount();i++) {
var c1 = obj.getCellText(0, i);
var c2 = obj.getCellText(1, i);
var c3 = obj.getCellText(2, i);
var a = new AW.HTTP.Request;
a.setParameter("C1", c1);
a.setParameter("C2", c2);
a.setParameter("C3", c3);
a.setParameter("C4", c4);
a.setParameter("C5", c5);
a.setURL("HTTPResponse.php");
a.setRequestMethod("POST");
a.request();
}
}
document.write(obj);
document.write(print);
</script>
Here's the example HTTPResponse.php
<?php
//Creates the file for $data array
$myFile = "body.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = $_POST[C1].";".$_POST[C2].";".$_POST[C3].";".$_POST[C4].";".$_POST[C5].";"."\n";
fwrite($fh, $stringData);
fclose($fh);
?>
Here is the example file it creates
MSFT;Microsoft Corporation;314,571.156;;;
SAP;SAP AG (ADR);40,986.328;;;
ORCL;Oracle Corporation;62,615.266;;;
MSFT;Microsoft Corporation;314,571.156;;;
SAP;SAP AG (ADR);40,986.328;;;
;;;;;
;;;;;
;;;;;
;;;;;
ORCL;Oracle Corporation;62,615.266;;;
As you can see the order of the lines is not the same as the grid...
Please advice
JEz
November 21,