这是我想要完成的。从php中插入一个数组到一个HTML表单中,然后将这个数组推入一个JS数组中。数组从PHP到HTML输入到JS
PHP
$proxiearray = array();
if($row7['attribute_0'] != NULL) { array_push($proxiearray,$row7['attribute_0']);}
if($row7['attribute_1'] != NULL) { array_push($proxiearray,$row7['attribute_1']);}
<input type="hidden" class="proxie_attributes" value="'.htmlspecialchars(json_encode($proxiearray)).'">
现在我想的是什么是对uppon在客户端有一定的任务为我的JS拿那个阿雷和另外一个推动它。
JS
attributesArray[counter] = new Array();
if(proxiearray) { attributesArray[counter] = proxiearray; }
如果我提醒阵列我得到 ["1","4"],5,6
这只是把数组中的["1","4"]
,但我希望它推的是有像 1,4,5,6
我知道我可以使用X数量的输入,尽管这不是一个解决方案,因为我可能不得不在未来使用更多的属性。编辑:alert
是attributesArray
。 attributesArray[counter]
提醒是["1","4"]
什么是计数器在'attributesArray [counter] = new Array();'? –
属性数组内部的数组。编辑问题 – LefterisL