# ExternalInterface/Javascript

**URL:** <https://forum.kirupa.com/t/externalinterface-javascript/289625>\
**Category:** flash\
**Created:** [June 2, 2009, 6:05pm UTC](https://forum.kirupa.com/t/externalinterface-javascript/289625 "2009-06-02T18:05:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThaJock](https://avatars.discourse-cdn.com/v4/letter/t/9de0a6/32.png) [@ThaJock](https://forum.kirupa.com/u/ThaJock)\
**Post date:** [June 2, 2009, 6:05pm UTC](https://forum.kirupa.com/t/externalinterface-javascript/289625/1 "2009-06-02T18:05:53Z")

</div>

I have a little problem that I’ve spent hours trying to figure out. I am trying to return an array from javascript. The problem (I assume) is that is has some php in the javascript function

Here is the code I am trying that doesnt work:  
_JavaScript:_  
\<script type=“text/javascript”\>  
function JavaFunc(){  
\<?php  
$company\_name[0] = “Kirupa”;  
echo ‘var company\_name = new Array();’;  
echo ‘company\_name[0] = ‘.$company\_name[0].’;’;  
echo ‘return company\_name;’;  
?\>

```
        }

```

\</script\>

_AS3_  
var theArray = ExternalInterface.call(“JavaFunc”);  
theTextField.text = theArray[0]

if I change the javascript code to…

\<script type=“text/javascript”\>  
function JavaFunc(){  
\<?php  
echo ‘var company\_name = new Array();’;  
echo ‘company\_name[0] = “Kirupa”;’;  
echo ‘return company\_name;’;  
?\>

```
        }

```

\</script\>  
The textfield text is the first element of the array as it should. There must be something wrong with the way I’m echoing out the java from php. If anyone can help me understand what I’m doing wrong I would greatly appreciate it.
