title: Passing an array to a javascript onclick function
body: <p>I have an array that I want to pass to a javascript onclick function.</p>
  
  <pre><code>                var event_data = new Array();
                  event_data.push(event_id);
                  event_data.push(event_title);
                  event_data.push(channel_id);
                  event_data.push(channel_name);
                  event_data.push(channel_onclick);
                  event_data.push(event_site);
                  event_data.push(event_url);
                  event_data.push(event_onclick);
                  event_data.push(start_date);
                  event_data.push(start_time);
                  event_data.push(end_date);
                  event_data.push(end_time);
                  event_data.push(event_notes);
  </code></pre>
  
  <p>I send that array in the onclick event of a button.</p>
  
  <pre><code>var span_string = '&lt;span id=\"dt'+event_id+'\"&gt;'+print_span+'&lt;br/&gt;&lt;button href="#" onclick="edit_event('+event_data+');" style="width: 49px;"&gt;Edit&lt;/button&gt;&lt;button href="#" onclick="delete_event();" style="width: 49px;"&gt;Delete&lt;/button&gt;&lt;/span&gt;';
  var event_id_string = 'mn'+event_id;
  $('#'+event_id_string).append(span_string);
  </code></pre>
  
  <p>The onclick function isn't called at all with that code.  Is there a different way to do call that function with the event_data array?</p>
  
  <pre><code>function edit_event (event_data) {
  /* function edit_event () { */
      alert ('edit event'); 
      var event_id = event_data[0];
      var event_title = event_data[1];
      var channel_id = event_data[2];
      var channel_name = event_data[3];
      var channel_onclick = event_data[4];
      var event_site = event_data[5];
      var event_url = event_data[6];
      var event_onclick = event_data[7];
      var start_date = event_data[8];
      var start_time = event_data[9];
      var end_date = event_data[10];
      var end_time = event_data[11];
      var event_notes = event_data[12];
  
      var alert_string = 'event id '+event_id+'&lt;br/&gt;'+
      'event title '+event_title+'&lt;br/&gt;'+
      'channel id '+channel_id+'&lt;br/&gt;'+
      'channel name '+channel_name+'&lt;br/&gt;'+
      'channel onclick '+channel_onclick+'&lt;br/&gt;'+
      'event site '+event_site+'&lt;br/&gt;'+
      'event url '+event_url+'&lt;br/&gt;'+
      'event onclick '+event_onclick+'&lt;br/&gt;'+
      'start date '+start_date+'&lt;br/&gt;'+
      'start time '+start_time+'&lt;br/&gt;'+
      'end date '+end_date+'&lt;br/&gt;'+
      'end time '+end_time+'&lt;br/&gt;'+
      'notes '+event_notes+'&lt;br/&gt;';
  
      alert (alert_string);
  }
  </code></pre>