:: Forum >>
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)
Thursday, March 2, 2006
$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
Thursday, March 2, 2006
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)
Friday, March 3, 2006
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)
Friday, March 3, 2006
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)
Friday, March 3, 2006
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)
Friday, March 3, 2006
Try this:
$html .='document.write("<option value="+c+">"+'.$name.'_columns[c]+"</option>");\n';
Rob Francis
Friday, March 3, 2006
Cristina(Spain)
Friday, March 3, 2006
This topic is archived.
Back to support forum
Forum search