Hello,
I am new to the Web2Py, Python stack and am struggling in implementing a basic
form based functionality. Basically, I have a view with two panes - left pane
for input data and right pane for displaying the output. User enters
information in the left pane and I need to pass that information to the
Controller action and send the results back to the view which I need to render
appropriately. The view is made with Bootstrap and HTML and is ready.
I am using AJAX call to send the data from Input Form to the Controller action
as shown below:
<script>
jQuery('#input_form').submit(function() {
ajax('{{=URL('process_form')}}',
['inputVar1','inputVar2','inputVar3','inputVar4'],
'target_div');
return false;
});
</script>
The Controller action in default.py has the following code for now:
def process_form():
results = request.vars
return DIV(results)
The 'target_div' is another Form which should display the response/results in a
table for example as:
<div id="target_div">
<form>
<div class="table-responsive">
<table id="records_table" class="table table-bordered">
<tr>
<th>Col1</th>
<th>Col2</th>
<th>Col3</th>
<th>Col4</th>
</tr>
<tr>
<td>1</td>
<td>Response val11</td>
<td>Response val12</td>
<td>Response val13</td>
</tr>
<tr>
<td>2</td>
<td>Response val21</td>
<td>Response val22</td>
<td>Response val23</td>
</tr>
</table>
</form>
</div>
When I run this code it simply replaces the entire contents of the
'target_div'. How can I render the response in such a way that it dynamically
generate the HTML as shown in HTML form above with a table containing
appropriate content?
All your help would be greatly appreciated.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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/d/optout.