JSFiddle - React, Tailwind, and code Playground
HTML
<form id="form_id">
<input type="text" name="service[]" value="foo"><br>
<input type="text" name="service[]" value="bar"><br>
<input type="text" name="service[]" value="baz"><br>
<input type="submit">
</form>
<p id="result"></p>
CSS
p:before { content:'Resulting array: '; }
p:empty:before { content:''; }
JavaScript
var $form = $('#form_id'),
$inputs = $form.find('input[name^=service]');
$form.on('submit', function(event) {
// Build an array only containing the services values
var values = [];
$.map($inputs, function(e) {
values.push(e.value);
});
$('#result').text(JSON.stringify(values));
event.preventDefault();
});