Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7613121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:05:10+00:00 2026-05-31T02:05:10+00:00

I have an array that I want to pass to a javascript onclick function.

  • 0

I have an array that I want to pass to a javascript onclick function.

                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);

I send that array in the onclick event of a button.

var span_string = '<span id=\"dt'+event_id+'\">'+print_span+'<br/><button href="#" onclick="edit_event('+event_data+');" style="width: 49px;">Edit</button><button href="#" onclick="delete_event();" style="width: 49px;">Delete</button></span>';
var event_id_string = 'mn'+event_id;
$('#'+event_id_string).append(span_string);

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?

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+'<br/>'+
    'event title '+event_title+'<br/>'+
    'channel id '+channel_id+'<br/>'+
    'channel name '+channel_name+'<br/>'+
    'channel onclick '+channel_onclick+'<br/>'+
    'event site '+event_site+'<br/>'+
    'event url '+event_url+'<br/>'+
    'event onclick '+event_onclick+'<br/>'+
    'start date '+start_date+'<br/>'+
    'start time '+start_time+'<br/>'+
    'end date '+end_date+'<br/>'+
    'end time '+end_time+'<br/>'+
    'notes '+event_notes+'<br/>';

    alert (alert_string);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:05:11+00:00Added an answer on May 31, 2026 at 2:05 am

    I ended up with this approach.

    Make events data a global variable.

    var events_data;
    

    Pass event_id to the edit_event() function.

    var span_string = '<span id=\"dt'+event_id+'\">'+print_span+'<br/><button href="#" onclick="edit_event(\''+event_id+'\');" style="width: 49px;">Edit</button><button href="#" onclick="delete_event();" style="width: 49px;">Delete</button></span>';
    

    Get event data for selected event_id in the edit_event function.

        function edit_event (event_id) {
            for ( var i=0; i<events_data.event_id.length; i++ ) { 
                var site = "";
                var onclick =  "";
                if ( event_id == events_data.event_id[i]["0"] ) {
                      .
                      .
                      .
                }
             }
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP array that I want to pass to the jQuery function
I have one array. I want that array to retain its value between function
I have an array of arrays that I want to pass into a DLL.
I Have an Array of users that i want to pass into a view
I have an array of values that I want to pass in as a
I have an array that I want to sort based on the value of
I have an array that I want on multiple pages, so I made it
I have an associative array that I want to display using TileList. However, it
I have a three-dimensional array that I want to reset to zero. It seems
I have an multi-dimensional array that I want to send to a PHP script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.