Hi,
The controller returns rows from building table via which the dropdown is
populated. When a user selects a building from the dropdown, the address of
the building should be displayed in the paragraph tag. Here is what I have
done so far,
*Controller*
def index():
return db(db.building).select()
*View*
<select id="buildings" onchange="displayBuidlingDetails()">
{{for building in buildings:}}
<option value="{{=building.id}}">{{=building.address}}</option>
{{pass}}
</select>
<p id="buildingAddress"></p>
<script>
function displayHomeDetails() {
var selected_building = $('#buildings').val();
$('#buildingAddress').text({{=(next(building.address for building
in buildings if building.id == selected_building)}});
</script>
Is there a way to select an item from the buildings list based on dropdown
value (something related to what's highlighted in yellow above)? I am
already familiar with how to use an ajax request for this, but I would like
to do this without an additional request (if possible).
Thanks
--
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.