Hi,
Please could someone tell me why this won't work (see between 'THIS PART
NOT WORKING - START' and 'THIS PART NOT WORKING - END' in code entered
below.
In a nutshell, once a form is processed, I want to stay on same page
(successfully achieved) and also update a <div> (ID =
'scan_info_previous') (won't work).
I'm fairly new to web programming.
Best regards
Ann
////////////////////////////////////////////////////////////////
{{response.files.append(URL('static','css/columns_2_Liquid.css'))}}
{{response.files.append(URL('static','js/input_patient_form.js'))}}
{{extend 'layout.html'}}
{{def get_entry_html(scan_instance_tree): }}
{{ get_entry_node_html(scan_instance_tree.child_nodes, -1, True) }}
{{ return }}
{{def get_entry_node_html(a_nodes, a_parent_id, a_is_root): }}
{{if a_is_root == False:}}
{{str_class = 'class=field_dependancy_group'}}
{{str_display = 'style=display:none'}}
{{else:}}
{{str_class = ''}}
{{str_display = 'style=display:block'}}
{{pass}}
<div id="has_parent_id_{{=a_parent_id }}" {{=str_display}}
{{=str_class}} >
</br>
{{for child_node in a_nodes:}}
{{=child_node.field_name }}
<select id='field_phenotype_id_{{=child_node.field_phenotype_id}}'
name='{{=child_node.field_phenotype_id}}'
{{if len(child_node.child_nodes) > 0:}}
class="parent_field_select"
{{else:}}
class='leaf_field_select'
{{pass}}
>
{{for value in child_node.values:}}
{{str_selected = ''}}
{{if (value['value'] == 0): }}
{{str_selected = ' selected=selected'}}
{{pass}}
<option value= {{=value['value']}} {{=str_selected}} >
{{=value['description']}}
</option>
{{pass}}
</select>
{{=A(IMG(_id="img_help", _src=URL("static","images/help.png"),
_alt="My Logo"),
callback=URL("default","get_phenotype_help",
vars=dict(field_id=child_node.field_phenotype_id)
), target="scan_field_extra")}}
</br></br>
{{if len(child_node.child_nodes) > 0:}}
{{get_entry_node_html(child_node.child_nodes,
child_node.field_phenotype_id,
False)}}
{{pass}}
{{pass}}
</div>
{{return}}
<div id="masthead">
<H1> {{=response.title or request.application}} Project</H1>
</div>
<div id="content">
<div id="patient_info" class="layout_block">
<h3>Patient Data</h3>
<form id="patient_form">
<fieldset>
<table>
<tr>
<td> Patient ID (or leave empty for new patient):
<input name="patient_id"
id="patient_id" value=12></td>
<td><input type="submit" value="Search Patient"></td>
<div id="open_clearcanvas_target"></div>
</tr>
</table>
</fieldset>
</form>
</div>
<!--field_new_group = field_is_new_group,
field_parent_group = field_row.field_phenotype_group.field_head_fk,
field_parent_dependancy =
field_row.field_phenotype_functional_dependancy.field_head_fk,
-->
<form id="scaninstance_form" action="{{=URL('add_new_scan')}}"
method="post">
<fieldset>
<input name=hidden_patient_id id=hidden_patient_id
style="display:none">
<div id="source_input">
<table>
<tr>
<td>Source: <input type="text" name="source"
id="source"></td>
<td>Diagnosis: <input type="text" name="diagnosis"
id="diagnosis"></td>
</tr>
</table>
</div>
<h3>New Scan Data</h3>
<input type='submit' value='Submit New Scan Data'> </br> </br>
<input type='button' value='Update Scan Type'> </br> </br>
<div id="scan_info" class="layout_block">
Age in Months: <input type="text" name="age_months"
class="field_input"
value='4444'>
{{response.write(get_entry_html(scan_instance_tree),
escape=False)}}
</div>
</fieldset>
</form>
</br>
<div id="scan_info_previous" class="layout_block">
</div>
</div>
<div id="sidebar">
<div id="patient_extra">
</div>
<div id="scan_field_extra">
</div>
</br>
</br>
<div id="model_field_extra">
<H3> Phenotype Occurrences / Predictive Values </H3>
<H4> for Cortical-Cerebral: Gyriform - Depths of Sulci</H4>
<table cellpadding=3 cellspacing=3>
...
</table>
</div>
</div>
<div id="footer">
...
</div>
<script>
$('#patient_form').submit(function(){
ajax('{{=URL('get_patient_info')}}',['patient_id'],
'source_input');
ajax('{{=URL('open_patient_images_clearcanvas')}}',['patient_id'],
'open_clearcanvas_target');
ajax('{{=URL('get_patient_scan_info')}}',['patient_id'],
'scan_info_previous');
return false;
});
$('#patient_id').change(function(){
document.getElementById("hidden_patient_id").value =
document.getElementById
("patient_id").value;
return false;
});
$(document).ready(function(){
document.getElementById("hidden_patient_id").value =
document.getElementById
("patient_id").value;
$form = $('#scaninstance_form');
$form.submit(function(){
$.post($(this).attr('action'), $(this).serialize(),
function(response){
************ THIS PART NOT WORKING - START **************
$('scan_info_previous').load("{{=URL('get_patient_scan_info')}}",
document.getElementById("hidden_patient_id").value);
OR I've also tried...
ajax('{{=URL('get_patient_scan_info')}}',['hidden_patient_id'],
'scan_info_previous');
************ THIS PART NOT WORKING - END **************
},'json');
return false;
});
$(".parent_field_select").change(function(){
if ($(this).val() == 0) {
$(this).nextAll("div").first().slideUp();
}
else{
$(this).nextAll("div").first().slideDown();
}
});
});
</script>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.