Jump to content

[SOLVED] [this.selectedIndex].value"> validate


saltem8

Recommended Posts

i have this, but i am trying to get it to validate, i have solved most the errors but it is just one that is getting the better of me, here is the code

 

<?php

    //get this month and year
    $month = date("n");
    $year = date("Y");
    
    $jump = isset($_POST['jump']) ? $_POST['jump'] : (isset($_GET['jump']) ? $_GET['jump'] : $month);

    require('main.php');
    
    $month_tots = array();
    for ($i=1; $i<=12; $i++) $month_tots[$i] = 0;       // ensure total for every month

    $res = mysql_query ("SELECT MONTH(FROM_UNIXTIME(date)) as mth, COUNT(*) AS num 
                        FROM form
                        WHERE YEAR(FROM_UNIXTIME(date)) = '$year'
                        GROUP BY mth");
     while (list($mth, $num) = mysql_fetch_row($res)) 
     {
         $month_tots[$mth] = $num;         // put month totals in the array
     }
     
     /**
     * create the dropdown
     */
     echo '<form method="post" action="" >
     <select name="jump" id="jump"  onchange="location.href=this.options[this.selectedIndex].value"> ';
     foreach ($month_tots as $m => $num)
     {
         $sel = $jump==$m ? 'selected="selected"':'';
         $dt = date ('F Y', mktime(0,0,0,$m, 1, $year));
         echo "<option value='index.php?jump=$m' $sel>$dt ($num)</option>";
     }
     echo '</select></form>'; ?>
     
    <?php mysql_close($conn); ?>

 

this is the offending line

     <select name="jump" id="jump"  onchange="location.href=this.options[this.selectedIndex].value"> ';

 

and this is the error

 

line 44 column 99 - Error: document type does not allow element "select" here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", "del" start-tag

 

does anyone know how this can be fixed, thank you

Link to comment
https://forums.phpfreaks.com/topic/90111-solved-thisselectedindexvalue-validate/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.