Passing Array From PHP to JQuery json_encode
<p>I have an HTML form generated by php which has a dropdown of voucherproviders.</p>

<p>I want to select the provider and have this populate the form for editing.</p>

<p>Here is my JQuery code:</p>

<pre><code>$(document).ready(function() { 
    $(document).on('change','#id_voucherprovider',function(){
        var voucher_providers = &lt;?php echo json_encode($voucher_providers); ?&gt;;

        //The value I have got from the drop down is....
        var value = $('#id_voucherprovider option:selected').val();
        var vendortext = $('#id_voucherprovider option:selected').text();
        //so the voucher provider is
        alert(vendortext);

        $('.ftext input').val(vendortext);
        $("textarea#id_vendornotes").val(voucher_providers[value]);
    });
}); 
</code></pre>

<p>voucherproviders is not being passed into the JQuery despite the <code>echo json_encode($voucher_providers);</code> code working when inline with the php code.</p>

<p>It seems to return a null array.  Can anyone see what is wrong?</p>

<p>Many Thanks</p>

<p>Dave</p>