Row content to array on button click
I'm trying to retreive the data from a row upon clicking a button, but I'm not sure how to achieve this. Could some please offer advice. Here is a portion of my grid code
displayRules.php -------------------->
...
<style>
.active-controls-grid {font:menu;}
.active-row-cell {border-right: 1px dotted #99ccff}
.active-column-0 {width:0px; text-align:center;}
.active-column-1 {width:120px}
.active-column-2 {width:220px}
.active-column-3 {width:100px}
.active-column-4 {width:100px}
.active-column-5 {width:110px}
.active-image-activeLight {background: url("../images/ActiveRuleDark2.jpg")}
.active-image-deactiveLight {background: url("../images/InactiveRuleDark2.jpg")}
</style>
<?php
// add grid to the page
echo activewidgets_grid($name, $data);
?>
.....
//Onclick of image, place selected/highlighted row content into an array
<a href="toggleRule.php"><img src="../images/ToggleUp.gif" ></a>
activeWidget.php ---------------------------------->
...
$row_count = @mysql_num_rows($data);
$column_count = @mysql_num_fields($data);
//Set column names
$columnsHeaders = "var ".$name."_columnsHeaders = [\n";
$columnsHeaders .= "\"".Status."\",";
$columnsHeaders .= "\"".Name."\",";
$columnsHeaders .= "\"".Description."\",";
$columnsHeaders .= "\"".Created."\",";
$columnsHeaders .= "\"".Table."\",";
$columnsHeaders .= "\"".Chain."\",";
$columnsHeaders .= "\n];\n";
//Create array of row header images and row data
$myImages = "var ".$name."_myImages = [\n";
$rows = "var ".$name."_data = [\n";
while ($result = @mysql_fetch_array($data)) {
$rows .= "[";
for ($i=0; $i < $column_count; $i++) {
$rows .= "\"".activewidgets_html($result[$i])."\", ";
//Status image
if($result[0]=='1')
$myImages .= "\"".activeLight."\", ";
else if($result[0]=='0')
$myImages .= "\"".inactiveLight."\", ";
}
$rows .= "],\n";
}
$rows .= "];\n";
$myImages .= "\n];\n";
$myBlank = "var ".$name."_myBlank = [\n";
$myBlank .= "\"".''."\",";
$myBlank .= "\n];\n";
$html = "<"."script".">\n";
$html .= $columns;
$html .= $rows;
$html .= $columnsHeaders;
$html .= $myImages;
$html .= $myBlank;
$html .= "try {\n";
$html .= " var $name = new Active.Controls.Grid;\n";
$html .= " $name.setRowCount($row_count);\n";
$html .= " $name.setColumnCount($column_count);\n";
$html .= " $name.setColumnText(function(i){return ".$name."_columnsHeaders[i]});\n";
$html .= " $name.setRowProperty(\"text\", function(i,j){return ".$name."_myBlank[0]});\n";
$html .= " $name.setRowProperty(\"image\", function(i,j){return ".$name."_myImages[i]});\n";
$html .= " $name.setDataText(function(i,j){return ".$name."_data[i][j]});\n";
$html .= " document.write($name);\n";
$html .= "}\n";
$html .= "catch (error){\n";
$html .= " document.write(error.description);\n";
$html .= "}\n";
$html .= "</"."script".">\n";
return $html;
...
---------->
Thank you
displayRules.php -------------------->
...
<style>
.active-controls-grid {font:menu;}
.active-row-cell {border-right: 1px dotted #99ccff}
.active-column-0 {width:0px; text-align:center;}
.active-column-1 {width:120px}
.active-column-2 {width:220px}
.active-column-3 {width:100px}
.active-column-4 {width:100px}
.active-column-5 {width:110px}
.active-image-activeLight {background: url("../images/ActiveRuleDark2.jpg")}
.active-image-deactiveLight {background: url("../images/InactiveRuleDark2.jpg")}
</style>
<?php
// add grid to the page
echo activewidgets_grid($name, $data);
?>
.....
//Onclick of image, place selected/highlighted row content into an array
<a href="toggleRule.php"><img src="../images/ToggleUp.gif" ></a>
activeWidget.php ---------------------------------->
...
$row_count = @mysql_num_rows($data);
$column_count = @mysql_num_fields($data);
//Set column names
$columnsHeaders = "var ".$name."_columnsHeaders = [\n";
$columnsHeaders .= "\"".Status."\",";
$columnsHeaders .= "\"".Name."\",";
$columnsHeaders .= "\"".Description."\",";
$columnsHeaders .= "\"".Created."\",";
$columnsHeaders .= "\"".Table."\",";
$columnsHeaders .= "\"".Chain."\",";
$columnsHeaders .= "\n];\n";
//Create array of row header images and row data
$myImages = "var ".$name."_myImages = [\n";
$rows = "var ".$name."_data = [\n";
while ($result = @mysql_fetch_array($data)) {
$rows .= "[";
for ($i=0; $i < $column_count; $i++) {
$rows .= "\"".activewidgets_html($result[$i])."\", ";
//Status image
if($result[0]=='1')
$myImages .= "\"".activeLight."\", ";
else if($result[0]=='0')
$myImages .= "\"".inactiveLight."\", ";
}
$rows .= "],\n";
}
$rows .= "];\n";
$myImages .= "\n];\n";
$myBlank = "var ".$name."_myBlank = [\n";
$myBlank .= "\"".''."\",";
$myBlank .= "\n];\n";
$html = "<"."script".">\n";
$html .= $columns;
$html .= $rows;
$html .= $columnsHeaders;
$html .= $myImages;
$html .= $myBlank;
$html .= "try {\n";
$html .= " var $name = new Active.Controls.Grid;\n";
$html .= " $name.setRowCount($row_count);\n";
$html .= " $name.setColumnCount($column_count);\n";
$html .= " $name.setColumnText(function(i){return ".$name."_columnsHeaders[i]});\n";
$html .= " $name.setRowProperty(\"text\", function(i,j){return ".$name."_myBlank[0]});\n";
$html .= " $name.setRowProperty(\"image\", function(i,j){return ".$name."_myImages[i]});\n";
$html .= " $name.setDataText(function(i,j){return ".$name."_data[i][j]});\n";
$html .= " document.write($name);\n";
$html .= "}\n";
$html .= "catch (error){\n";
$html .= " document.write(error.description);\n";
$html .= "}\n";
$html .= "</"."script".">\n";
return $html;
...
---------->
Thank you
Avnish
February 25,