This topic is locked
[SOLVED]

 pass variable to js

9/28/2016 2:06:57 AM
PHPRunner General questions
M
mr.a021 author

hi all guys.excuse me for my poor english.i have problem in pass array to javascript onload and i cant use the array in javascript onload.please help me

romaldus 9/28/2016



hi all guys.excuse me for my poor english.i have problem in pass array to javascript onload and i cant use the array in javascript onload.please help me



Do you mean php array? Check my post here:
http://www.asprunner.com/forums/topic/24035-disable-field-on-addedit-page-based-on-value-from-other-table/

M
mr.a021 author 9/28/2016

my code in list page>before display

$sql = "SELECT ID feom table2";

$rs = CustomQuery($sql);

while($data = db_fetch_array($rs)){

$ID=json_encode(data["ID"]);

$pageObject->setProxyValue("ID", $ID);

}



i want use all IDs in javascript onload but when i used proxy['ID'] in javascript onload gived me last record ID

Admin 9/30/2016

You need to use a PHP array, right now you are using a scalar PHP variable $ID overwriting its value while looping through query results.
Check this article:

http://stackoverflow.com/questions/676677/how-to-add-elements-to-an-empty-array-in-php