In my javascript I am trying to pass a php variable through the html name tag. The html is appended to my selected options.
$("#a"+$selected.val()).append('<input type="hidden" name="<?php echo $event_id; ?>" value="'+$selected.text()+'">');
Here is the entire js function to see what is going on http://laravel.io/bin/Edz25
Now, I know for a fact and have tested in my view that $event_id is returning an array by doing the following in my controller and also echoing the variable in the view.
print_r($event_id);
die();
Controller:
$data['event_id'] = $this->model_location->get_event_id();
Model:
public function get_event_id()
{
$this->db->select('id');
$query = $this->db->get('table_eventcards');
return $query->result_array();
}
Now I am not sure why the variable in my javascript is not outputting anything.
Here is the output when I inspect the element.
<li data-value="28" id="a28">Event title<input type="hidden" name="<?php echo $event_id; ?>" value="Event title"></li>
If this helps this is my console log http://postimg.org/image/owtz3v8h7/
I really need to get this solved and appreciate all help.
$event_idis returning an array", and how do you expect to use an array as a name ?