Hi Marc,
as Rouslan said, please rewrite this function in jQuery, probably
passing to it the form name as a parameter. Then move it to js/functions.js.
Then you'll be able to call it from tbl_structure.js in your Ajax logic;
you'll be able to call this function also from indexes.js at load time.
Finally in tbl_indexes.php, instead on the "onchange", use jQuery in
indexes.js to bind to changes in select_index_type.