<!-- Template for loading old program -->
<div class="content-container fit-content" style="margin-left:auto;margin-right:auto;margin-top:50px;">
<h2>Load old program for Rig [% rig_info.name %]</h2>
<form method="post" action="/cgi-bin/celltest/setup_program.cgi" enctype="multipart/form-data" class="form">
[% INCLUDE print_hidden.tt %]
<table class="load_prog">
<tr><th>Select test</th><td>
[% x = 1 %]
<select name=test onchange="select_session(this.value)" autocomplete=off>
[% WHILE x <= rig_info.current_test -%]
<option value="[% x %]" [% IF x == rig_info.current_test %]selected=selected[% END %]>[% rig_info.name %]test[% x %]</option>
[% x = x + 1 -%]
[% END -%]
</select>
</td></tr>
<tr><th>Selct program</th><td>
<select name=file id=file>
[% FOR i IN data.files -%]
<option value="[% i %]">[% i %]</option>
[% END -%]
</select>
</td></tr>
<tr><td colspan=2>
<button name=action value="select_prog" class=rfcbutton style="float:right;">Load program</button>
</td></tr>
</table>
</form>
</div>

<style>

.load_prog {
   text-align:left;
   padding:20px;
}

.load_prog th, .load_prog td {
   padding:5px;
}

</style>


<script>

function select_session(t)
{
    run_ajax('rig_ajax_run.cgi','&action=get_programs_test&session='+t,set_progs);
    var e = document.getElementById('file');
    e.options.length = 0;
}

function set_progs(res)
{
    var e = document.getElementById('file');
    var arr = res.split("\n");
    for (x = 0; x < arr.length; x++)
    {
	var optn = document.createElement("OPTION");
        optn.value = arr[x];
        optn.text = arr[x];
        e.options.add(optn);
    }
}


</script>