3.2.0

Help error in sintaxis with php

I can't make a sentence in javascript with php


$html .="for(var c=0; c<$column_count; c++) { \n";
$html .='document.write("<option value=#c# >"'.$name.'_columns [c] "\" </option> "\");\n';
$html .="}\n";

I get an error with this for


Gracias, Danke schoen, Merci
Cristina (Spain)
March 2,
$html .="for(var c=0; c<" . $column_count . "; c++) { \n";
$html .='document.write("<option value=#c# >"'.$name.'_columns [c] "\" </option> "\");\n';
$html .="}\n";

try that
David Gutierrez
March 2,
this problem is in
$html .='document.write("<option value=#c# >"'.$name.'_columns [c] "\" </option> "\");\n';

no take to value ("<option value=#c# >"

please
Merci
Cristina (Spain)
March 3,

What php error you get? The code works in my machine in php with no errors. What value you expect to get with #c#?
joakinen (Spain)
March 3,
The Error Message is : Expected ')'

What value you expect to get with #c#?

I'am waiting for the c value :this is the index value of the column
I would like to show in the combobox

$name.'_columns [c] = name column

change "\" by \" and nothing

Merci

Cristina

Cristina(Spain)
March 3,

But "c" is a Javascript variable, not a PHP one. So when you are executing this PHP code, "c" is nothing but a literal. Is when that HTML code arrives at the client browser when you will get the Javascript executed.

If the data you want to include in the OPTION values is from a database you have to code the loop in PHP and concatenate all the "option value's" in the $html var.

This will be the pseucodode for that solution:

open database
fetch record
while not database.eof
$html .= <data_from_currect_record>
fetch next record
end while

If what you intend is to include in the OPTION values some information from the client environment, you have to do the same thing but in Javescript, sustituting database access for access to the relevant local data.

Hope I understood correctly your problem.


joakinen (Spain)
March 3,
Try this:

$html .='document.write("<option value="+c+">"+'.$name.'_columns[c]+"</option>");\n';
Rob Francis
March 3,
This modell is based in http://www.activewidgets.com/javascript.forum.797.17/searchable-grid.html

but I would like in PHP



Cristina


Cristina(Spain)
March 3,

This topic is archived.

See also:


Back to support forum