I have some problem with on of the pages of a project. I have 1 drop down on top o开发者_如何学Gof the page , and in that list the items are - today , last week. Now according to that list item-value , below that drop down list records should be displayed from the database.
dummy code:
if today
then
records with current date should be displayed
and if last week
then
records with date in last week should be displayed
First drop-down on which 2nd drop-down will be shown -
<select name="day" onchange="itemsToShowFor();">
<option value="today">Today</option>
<option value="last_week">Last Week</option>
</select>
Container of Table - Records
<div id="records"></div>
Script for update Table of Records -
<script type="text/javascript">
$(document).ready(function(){
itemsToShowFor();
});
function itemsToShowFor(){
var itemToShowFor = $("select:[name=day]").val();
$.ajax({
type:'POST',
url:URL_TO_GET_ITEMS,
data:[day:itemToShowFor ],
success:function(list){
$("#records").html(list); // list will contain records formatted with HTML
}
});
}
</script>
精彩评论