Question: I have a question regarding array's performance with huge amount of elements. I have this big array that currently has about 100 elements and I will keep adding to it in the future so it will get larger and larger with time. My question is, will there be a huge performance impact when this array gets to 500+ elements or more?

```
  $pages=array(
  '<div class="article"><img src="image url here"></div>',
  '<div class="article"><img src="image url here"></div>',
  '<div class="article"><img src="image url here"></div>',
  '<div class="article"><img src="image url here"></div>',
  '<div class="article"><img src="image url here"></div>',
  '<div class="article"><img src="image url here"></div>',
  '<div class="article"><img src="image url here"></div>',
  '<div class="article"><img src="image url here"></div>');
  }

```

Answer: 
In the same way as setting `id` in `#id` field like,

```
$('#modalEditGroup').on('show.bs.modal', function(e) {
  var t=$(e.relatedTarget),
      id = t.data('id'),
      gname=t.data('gname'),
      alevel=t.data('alevel'),
      appby=t.data('appby');
     $('#id').val(id);
     $('#group_name_edit').val(gname);
     $('#access_level_edit').val(alevel);
     $('#approve_by_edit').val(appby);
});

```

Add `data-*` in HTML like,

```
<input type="button" id="edit-group" name="edit-group" 
   class="btn btn-primary btn-xs" 
   data-id="<?php echo $row['group_id'];?>" 
   data-gname="<?php echo $row['group_name'];?>" 
   data-alevel="<?php echo $row['access_level'];?>"
   data-appby="<?php echo $row['approve_by'];?>" 
   data-toggle="modal" data-target="#modalEditGroup" 
   value="Edit" />

```

And add on submit event like,

```
$('#submit').on('click',fucntion(){
   $.ajax({
      url:'YOUR-URL-TO-SUBMIT-DATA',
      type:'post',
      data:{
          id:$('#id').val(),group_name:$('#group_name_edit').val(),
          access_level:$('#access_level_edit').val(),
          approve_by:$('#approve_by_edit').val()
      },
      success:function(data){
          // check for success and error messages
          // if success then hide modal box and alert('Success'); 
      }
   });
});

```
On click of edit button before showing the modal, make an `ajax` call the `ID` and get the details of associated with that `ID` and fill it to the `modal` elements and than show the modal.

Ex:

```
$('#modalEditGroup').on('show.bs.modal', function(e) {
     var id = $(e.relatedTarget).data('id');
     // make ajax() call here with the id
     // fill the response in the the modal
     // show the modal
});

```