This can be a continuation of the earlier post. Regrettably, The solutions published did not work and my follow-up questions were not addressed. Just just in case the reason being my generous participants did not notice I'd responded, I am reposting my problem.


I am attempting to develop a form where certain text fields and text areas have autocomplete.

I have used the formidable wordpress plugin for wordpress to construct my form. I am while using jQuery autocomplete plugin for that autocomplete part.

After applying the suggestions of 1 of my participants, the code now appears like this:

<script> 
$(document).ready(function(){ 
<?php global $frm_entry_meta; 
$entries = $frm_entry_meta->get_entry_metas_for_field(37, $order=''); ?> 
var data = new Array(); <?php foreach($entries as $value){ ?>
data.push(unescape('<?php echo rawurlencode($value); ?>'); 
<?php } ?> 
$("#field_name-of-the-school").autocomplete(data); }) 
</script>

// 37 is the field id I want to pull from in the database, 
// and #field_name-of-the-school is the css id 
// for the text field in the form where a user can enter the name of a school. 
// the data for that field is stored in the db under field id 37. 
// other fields, like school id, have their own field ids.

My respondent recommended adding the data.push(unescape('<?php echo rawurlencode($value); ?>'); bit. Regrettably, will still be no longer working.

BTW, the code is incorporated in the body of page.php, a template which wordpress uses to create static pages (the shape is on one of these simple).

I'd seriously, seriously appreciate every assist with this. If the approach is really a stalemate (around the earlier posts, there have been two other solutions which were over my mind,) I'd be willing to understand newer and more effective methods (although it would actually assistance to be pointed to some relevant learning resource.)

Thanks ahead of time.

I'd jsut use json_encode and simplify it:

<script> 
$(document).ready(function(){ 
  <?php global $frm_entry_meta; 
  $entries = $frm_entry_meta->get_entry_metas_for_field(37, $order=''); ?> 
  var data = <?php echo json_encode($entries); ?>;

  $("#field_name-of-the-school").autocomplete({source: data});
});  // note you were missing a semicolon at the end of this, which i added
</script>

Obviously while using above might not be waht you would like if $entries is definitely an associative array rather than a number indexed one. If thats the situation that you can do json_encode(array_values($entries));

Make use of

$("#field_name-of-the-school").autocomplete({ source : data });

as proven within the Autocomplete documentation example. Also you may think about using JSON.