This topic is locked

Filter Dropdown Based On Date Selected

3/18/2013 11:25:05 AM
PHPRunner General questions
S
Suety29 author

I use a date picker to select a start date and i'm trying to figure out how to filter a dropdown to only show the flights for the day of the week in the start date. Currently i'm using the javascript onload event to assign the day of the week to a variable. How do i get the query in the dropdown to use this variable in the where clause? Can anyone point me in the right direction?

C
cgphp 3/18/2013

You need an AJAX call to filter out the dropdown values when you change the date. To perform an asynchronous HTTP request you can use the jquery ajax wrapper. Check the API: http://api.jquery.com/jQuery.ajax/

S
Suety29 author 3/25/2013



You need an AJAX call to filter out the dropdown values when you change the date. To perform an asynchronous HTTP request you can use the jquery ajax wrapper. Check the API: http://api.jquery.com/jQuery.ajax/


Thanks for your assistance but i'm new to jquery and i'm not sure how to implement it in phprunner.
This is the code i tried in the JavaScript Onload event:



$(document).ready(function(){



$("#tsvalue_Arr_Date_1").change(function(){

$.post(window.location, {name: $("#value_Arr_Date_1").val()},

function(output) {

//this was inserted to test whether or not the code was getting the value from the Date textbox

//and output it to another textbox but nothing happens

$('#value_Arr_Heli_1').val(output).show();

});

});


What i'm trying to do is:

  1. get the value from the date field
  2. get the weekday for that date and pass it to a variable
  3. use this variable in the where clause for my flight lookup, so that the dropdown only shows me flights for that day of the week