Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.