Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2008
    Location
    Ohio
    Posts
    41
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Help with listbox onchange event

    I have three values in this table tl_academic_year as Academic_Year.

    0708
    0809
    0910

    They stand for academic years for the university I work at.

    I have the current academic year loaded in this table tl_config, as Academic_Year as well.

    I need a way to look at grades, and or anything else for that matter by a listbox and an onchange event to query by year.

    Here is an example:

    I first get the course number and then see if an onchange event has occurred. If not I get the current year loaded in the tl_config table and then pull all my data for that course.

    PHP Code:
    $Course_Number $_GET['Course_Number'];

    if(isset(
    $_POST["year_list"])) {
    $query_Year $_POST['year_list'];
    }else{
    //Get the default academic year
        
    $tl_config $db->sql_fetchrow($db->sql_query("SELECT * FROM `".$prefix."_tl_config`"));
        
    $query_Year $tl_config['Academic_Year'];
        }

    $sessionresult $db->sql_query("SELECT * FROM ".$prefix."_tl_session WHERE Course_Number = '$Course_Number' AND Academic_Year = '$query_Year' ORDER BY TLDate"); 
    My form looks like so:
    PHP Code:
    OpenTable();
    echo 
    "<form name=\"sessionList\" action='".$_server['php_self']."' method='post'>";
    echo 
    "<table width='100%' border='1' cellspacing='0' cellpadding='2'>\n";
    echo 
    "<tr><td colspan='3' width='100%' bgcolor='$bgcolor2'><nobr>TL Session Options for $Course_Name</nobr></td>";
    //Need a way to get all academic years so I can view any records
    $getYear $db->sql_query("SELECT Academic_Year FROM atlas_tl_academic_year ORDER BY Academic_Year");
    echo
    "<td> <SELECT name=\"year_list\ onchange=\"document.getElementById('sessionList').submit();\">";
    while(
    $row $db->sql_fetchrow($getYear)) {
    echo 
    '<option value="'.$row["Academic_Year"].'"';
    if(
    $row["Academic_Year"] == $query_Year) {
    echo 
    ' selected';
    }
    echo 
    '>'.$row["Academic_Year"].'</option>';
    }
    echo 
    '</select>';
    echo
    "</td></tr>\n";
    echo 
    "</form>"
    Nothing happens. The form does not refresh. I have tried this as well but nothing so far.

    PHP Code:
    onchange="this.sessionList.submit();\" 

  • #2
    New Coder
    Join Date
    Mar 2008
    Location
    Ohio
    Posts
    41
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I did this ...
    PHP Code:
    if(isset($_POST["year_list"])) {
    $query_Year $_POST['year_list'];
    OpenTable();
    echo 
    "$query_Year";    
    CloseTable();
    die();
    }else{
    //Get the default academic year
        
    $tl_config $db->sql_fetchrow($db->sql_query("SELECT * FROM `".$prefix."_tl_config`"));
        
    $query_Year $tl_config['Academic_Year'];
        } 
    and can see the correct value from the $query_Year and the page died so it is getting refreshed but I am not seeing any values for 0809. I have 5 records with Academic_Year = 0809 in my session table.

    This query should pull those records if $query_Year has the correct value.

    Code:
    SELECT * FROM ".$prefix."_tl_session WHERE Course_Number = '543' AND Academic_Year = '0809' ORDER BY TLDate
    I can't see where or if it is getting stepped on.

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Can we have a link to your page? There might be some errors in your html output. (Always validate your code)
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #4
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    something quick to try, change
    Code:
    document.getElementById('sessionList').submit();
    to
    Code:
    document.sessionList.submit();
    also, be careful of using single quotes inside double quotes. you can use doubles inside of singles, but not the other way around (without escaping them, of course)


    as for the query itself, if you have error reporting turned on it should say if it doesn't like the query. but to be sure, try running the query directly in smoething like phpmyadmin. it could give clues.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •