RSS Git Download  Clone
Raw Blame History
  [% META title = 'HMRN » Treatment & Trial Options' -%]

<!-- BEGIN [% template.name %] -->
	[% # PROCESS dumper.tt dump = opts %]

	[% # error_codes_dfv_js %]

	[% # PROCESS admin/misc_nav.tt page = 'error-codes' %]

  <h2 align="center">HMRN treatments &amp; clinical trial options</h2>

    [% IF dfv_errors %]
        <p class="error">[% c.config('msg').dfv_errors %]</p>
    [% END %]

	[% INCLUDE site/snippets/help.tt file = 'treatmentdetails' %]

	[% # PROCESS site/js/jquery.tt # already loaded in html_wrapper %]
	<script language="javascript" type="text/javascript">
	<!--
		function showhide_tx_detail(f,v) {
			var t = f.tx_detail_id;
			var tx_type_ids = [ [% opts.tx_type_ids.join(',') %] ];
			
			// does value of 'v' match any of tx_type_ids array:
			match = jQuery.grep(tx_type_ids, function (a) { return a == v; }); // alert(match);

			/* alternative:
			var match = 0;
			for (i=0; i<tx_type_ids.length; i++) {
				if (tx_type_ids[i] == v) {
					match = 1;
					break;
				}
			}
			if (match) { .. }
			*/
			
			if (match.length) { // ie contains the value of tx_type_id
				t.style.visibility='visible';
			}
			else {
				t.style.visibility='hidden';
			}			
		}

		// use addLoadEvent function in common.js for onload:
		[% visibility = opts.tx_details.size ? 'visible' : 'hidden' %]
		addLoadEvent(
			function() { 
				document.txDetails.tx_detail_id.style.visibility='[% visibility %]';
			}
		);

		// tx_type_id onChange event for tx_detail_id select menu
		$(document).ready(function () {
			$('#tx_type_id').change( function() {
				$('#tx_detail').load('[% app_url %]/hmrn_data/treatment_options', {
					tx_type_id: $('#tx_type_id').val()	
				})
			})
		});		
	-->
	</script>


	<form method="post" action="[% app_url %]/hmrn/treatment_options"
      [% error_codes_onsubmit %] name="txDetails" id="txDetails">
		<div class="indent">
			<table>
        <tr>
          <td class="label">Tx type:</td>
          <td class="content">
            <select name="tx_type_id" id="tx_type_id" id="tx_type_id"
                onchange="showhide_tx_detail(this.form,this.value)">
              <option value=""></option>
              [% FOREACH key IN opts.tx_types.keys.sort %]
                <option value="[% opts.tx_types.${key} %]">[% key %]</option>
              [% END %]
            </select>
            <span class="bold">OR NEW:</span>
            <input type="text" size="15" name="new_tx_type" />
            [% error_tx_type_id %]
          </td>
        </tr>
        <tr>				
          <td class="label">Tx detail:</td>
          <td class="content">
            <!-- // replaced by ajax output after selection of tx_type_id: -->
            <select name="tx_detail_id" id="tx_detail">					
              [% IF opts.tx_details.size %]
              <option value=""></option>
              [% FOREACH opt IN opts.tx_details %]
                <option value="[% opt.key %]">[% opt.value %]</option>
              [% END; END %]
            </select>
            <span class="bold">NEW:</span>
            <input type="text" size="15" name="new_tx_detail" />
            [% error_tx_detail_id %]
          </td>
        </tr>
      </table>

      <p class="indent">[% site.html.submit %]</p>
		</div>
	</form>
<!-- END [% template.name %] -->