Change label based on selected dropdown [Ruby on Rails 4.2]

my SO Link

I have a table called network it has the column type and number.

I use this select_tag to get a list of all my network names:

<%= select_tag(‘NetworksList’,
options_from_collection_for_select(Network.all, :id, :name))%>

I also have 2 label fields that I want to populate with information
dynamically:

Network Type: <%= content_tag('span', "", id: 'NetworkType') %>

Network Number: <%= content_tag('span', "", id: 'NetworkNumber') %>

When the user selects a network from the dropdown list of network names,
I want to show the selected item’s type and number in the fields named
NetworkType and NetworkNumber. I would like this to render in the view
immediately after the user selects a dropdown. How would I do this?

My current Javascript code
$("#NetworksList").change(function() {

    var networks = <%= raw(@networks.map(&:id).to_json) %>;
    var network_details = <%= raw(@networks.map {|network| 

[network.network_type, network.number] }.to_json) %>;

    var value = $(this).val();
    var network_index = $.inArray(value, networks);

    var networkType = network_details[network_index][0];
    var networkNumber = network_details[network_index][1];

    $("#NetworkType").text(networkType);
    $("#NetworkNumber").text(networkNumber);
});

I am getting the current error in js console,
TypeError: network_details[network_index] is undefined
help?