:: Forum >> Version 1 >>

Object doesn't support this property or method


can anybody help me. Im a newbie in programming and I need some help. I got an error ("Object doesn't support this property or method ") if add this line: html .= " $name.setID('grid1');\n"; in the activewidgets_grid function.

Thank you in advance.

here is my code

<html>
<head>
<title>ActiveWidgets Grid :: PHP Example</title>
<style> body, html {font: menu; background: threedface;} </style>

<link href="grid.css" rel="stylesheet" type="text/css" ></link>
<script src="grid.js"></script>


<style>
#grid1 {height: 200px; border: 2px inset; background: white}
#grid1 .active-column-1 {width: 200px; background-color: threedlightshadow;}

.active-column-2 {text-align: right;}
.active-column-3 {text-align: right;}
.active-column-4 {text-align: right;}

.active-grid-row {border-bottom: 1px solid threedlightshadow;}
.active-grid-column {border-right: 1px solid threedlightshadow;}

</style>

</head>
<body>
<?php

function activewidgets_grid($name, &$data){

$row_count = @mysql_num_rows($data);
$column_count = @mysql_num_fields($data);


$columns = "var ".$name."_columns = [\n";
for ($i=0; $i < $column_count; $i++) {
$columns .= "\"".@mysql_field_name($data, $i)."\", ";
}
$columns .= "\n];\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])."\", ";
}
$rows .= "],\n";
}
$rows .= "];\n";

$html = "<"."script".">\n";
$html .= $columns;
$html .= $rows;
$html .= "try {\n";
$html .= " var $name = new Active.Controls.Grid;\n";
$html .= " $name.setID('grid1');\n"; // I add this line to format my grid but I got "Object doesn't support this property or method" error. .
$html .= " $name.setRowCount($row_count);\n";
$html .= " $name.setColumnCount($column_count);\n";
$html .= " $name.setDataText(function(i, j){return ".$name."_data[i][j]});\n";
$html .= " $name.setColumnText(function(i){return ".$name."_columns[i]});\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;
}

function activewidgets_html($msg){

$msg = addslashes($msg);
$msg = str_replace("\n", "\\n", $msg);
$msg = str_replace("\r", "\\r", $msg);
$msg = htmlspecialchars($msg);

return $msg;
}


$docrot = ($_SERVER['DOCUMENT_ROOT'].'/config/db_config.php');
require ($docrot);
$connection = @mysql_connect($db_host, $db_user, $db_password) or die('Error in Connection');
$db = mysql_select_db("rdexpayrolldb");

// grid object name
$name = "obj";

// SQL query
$query = "SELECT * FROM mytable";

// query results
$data = mysql_query($query, $connection);

// add grid to the page
echo activewidgets_grid($name, $data);
?>
</body>
</html>
cmsamijon
Friday, April 29, 2005



This topic is archived.

Back to support forum

Forum search