Right now I have a function that works with a static array that is defined inside the function:
[code]
function put_picker(){
var vals = [1,2,3,4,5,6,7,8,
9,10,11,12,13,14,15,16,
17,18,19,20,21,22,23,24,
25,26,27,28,29,30,33,40,41,
44,46,51,54,55,66,68,69,
73,77,83,87,88,91,93,97,];
document.write(‘<div id=”container” class=”picker_container” style=”width:239px”>’);
for (ev in vals){
document.write(‘<div class=box onclick=”s(this)”>’+vals[ev]+'</div>rn ‘);
}
document.write(‘</div>’);
}
All this does is use css to make a table of numbers that are clickable (basically a number pad). I would like to be able to make it so the array is created in my php function and then passed to the javascript function for output. Here is what I have tried so far with no luck.
[code]
function put_picker(vals){
document.write(‘<div id=”container” class=”picker_container” style=”width:239px”>’);
for (ev in vals){
document.write(‘<div class=box onclick=”s(this)”>’+vals[ev]+'</div>rn ‘);
}
document.write(‘</div>’);
}
<?php
echo “<script type=”text/javascript”>
var vals = new array(“.join(‘,’ , $vals).”);
put_picker(vals);
</script>
And then I tried put the JS right in the code but still no luck:
[code]
<?php
echo “<script type=”text/javascript”>
var vals = new array(“.join(‘,’ , $vals).”);
document.write(‘<div id=”container” class=”picker_container” style=”width:239px”>’);
for (ev in vals){
document.write(‘<div class=box onclick=”s(this)”>’+vals[ev]+'</div>rn ‘);
}
document.write(‘</div>’);
</script>”;
?>
I have looked at the source html that is created from the above code and the array seems to be created fine, it’s just not passing it properly to the javascript. Any help would be great. Thanks
Nick