First I want to thank you guys here, because your posts have gotten me as close as I have been in the past week or so to resolve this; but I need help to finish this. I will admit, this process is still not clear in my mind and I am also exhausted to please bear with me
The script below has gotten me so close
What I need to accomplish: I need to grab some data from my db, stick it into an array and then access/use the
values in that array in my external javascript file. I’ll be using on the onload event.
<s c r i pt language="javascript1.2">
var arr = new array(<?php
$result = mysql_query("select account_id, display_name, id from field where account_id = $holdAcctID and required_flag = 1");
$count = mysql_num_rows($result);
if($count>0){
for( $i=0;$i<$count-1;$i++) {
$row = mysql_fetch_row($result);
echo $row[2],',';
}
$row = mysql_fetch_row($result);
echo $row[2],',';
}
?>);
</s c r ipt>
above script produces this in my view source page:
<s c ript language="javascript1.2">
**var arr = new array(2860,2861,2862,2863,2864,3293,3294,3296,3521,3523,);**
</s c ript>
Q1 – how can i update the above array, so it holds the data from the same like the example below:
as you can see, it currently only holds, displays the id value
myReqField[0]
[account_id] => 72
[display_name] => Client Contact Name
[id] => 2860
myReqField[1]
[account_id] => 72
[display_name] => Contact Phone
[id] => 2888
myReqField[2]
[account_id] => 72
[display_name] => Email Address
[id] => 2865
myReqField[3]
[account_id] => 72
[display_name] => Approval needed
[id] => 2841
Q2 – how easy would it be to do this and place the results into a comma separate list. If fairly easy how would I code that and how can I access the list/value from my external javascript
Q3 – If Q2 is not possible/easy to set up, how then do I pull the array in to javascript file. Several have mentioned json, but the other developer doesn’t want to use it.
Thank you in advance!
I know you said the other developer doesn’t want to use JSON but that’s exactly what you’re looking for. Is there a particular reason (s)he’s opposed to using it?