php - javascript problems with array -


i've write this:

document.getelementsbyname("elname[]")[0].value=array('val1','val2','val3', etc); 

my problem inside "array" elements, because have write inside values array initialized

var val_vec= new array(<?php echo $count ?>); 

i've tried this, doesn't work:

document.getelementsbyname("elname")[0].value=array(             for(var i=0; i< <?php echo $count ?> ; i++)             {                 document.write('"'+ val_vec[i] + '"');                 if(i!=<?php echo $count-1 ?>)                     document.write(',');             }); 

the 'if' condition writed because of commas betweens 'vars' (the last comma must not written!)

can me please?

your syntax makes no sense whatsoever. using for loop inside of array(…), complete nonsense.

if want array values comma-separated string, use .join()

or, if question how php array of values “transferred” javascript variable (really hard tell want know) – use php’s json_encode.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -