Hi,
is it possible to access an array declared in php in javascript ??
if so How ?
$allClasses = array();
echo '<td><input type="text" name="new_class_name" maxlength=64 size=20 onchange=checkNewName($allClasses)> </td>';
-----
<script language="JavaScript">
function checkNewName(a){
document.write("length: ",a.length);
}
</script>
accessing a php declared array in javascript
Moderator: General Moderators
please read Sticky: Before Post Read: Frames, JavaScript, and PHP Overview
you might output the content of the array to the document in a way that it can be access by javascript on the client, i.e.
you might output the content of the array to the document in a way that it can be access by javascript on the client, i.e.
Code: Select all
<?php
$phpArrary = array();
....
?>
...
<script language="JavaScript">
var jsArray = new Array(<?php echo implode(',', $phpArrary); ?>
....