2 Replies Latest reply: Feb 18, 2012 1:51 AM by whatalotofrubbish RSS

    W3C error with select elements

    whatalotofrubbish Community Member

      I am getting the following error message when using the W3C Validator on a HTML5 page in CS5.5:

      Line 79 No space between attributes [HTML5]

      Line 81 No space between attributes [HTML5]

      Line 81 The select element cannot have ,ore than one selected option descendant unless the multiple attribute is specified [HTML5]

      Line 82 No space between attributes [HTML5]

      Line 82 The select element cannot have ,ore than one selected option descendant unless the multiple attribute is specified [HTML5]

       

      The error appears when it checks a dynamic populated list created by Dreamweaver.

      For every item in the list, I get the error shown in lines 81 and 82. The line 79 error always appears first..

      The page works fine.

       

      I did a search for this error on the web, and found that it was reported as a bug in the validator some time ago, but another report says that the bug has now been fixed.

       

      When the validator stays on the page for longer than a few seconds with this error, Dreamweaver reports that it has ;lost contact with the  (local) Apache server. Dreamweaver has to be restarted to fix it.

       

      Is this a bug in the validator or is it an error in the Dreamweaver list menu code.

       

      It happens in any dynamically populated list with Dreamweaver generated with code like this:

       

      <select name="pick" size="11" class="selectblue">

          <?php

      do { 

      ?>

          <option value="<?php echo $row_Recordset1['club_index']?>"<?php if (!(strcmp($row_Recordset1['club_index'], $row_Recordset1['club_index']))) {echo "selected=\"selected\"";} ?>>

           <?php echo $row_Recordset1['club_name']?></option>

          <?php

           } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));

             $rows = mysql_num_rows($Recordset1);

             if($rows > 0) {

                 mysql_data_seek($Recordset1, 0);

                 $row_Recordset1 = mysql_fetch_assoc($Recordset1);

             }

      ?>

        </select>

      Is this a bug in the validator or is it an error in the Dreamweaver list menu code.

        • 1. Re: W3C error with select elements
          whatalotofrubbish Community Member

          The code inserted by Dreamweaver is like this:

          <option value="<?php echo $row_Recordset1['incometype']?>"<?php if (!(strcmp($row_Recordset1['incometype'], $row_Recordset1['incometype']))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset1['incometype']?></option>

          and generates errors.

          If the code is split like this:

          <option value="<?php echo $row_Recordset1['incometype']?>"

            <?php if (!(strcmp($row_Recordset1['incometype'], $row_Recordset1['incometype']))) {echo "selected = \"selected\"";} ?>><?php echo $row_Recordset1['incometype']?></option>

          Then all the errors regarding space between elements disappear.

          This also happens if a space is inserted between the code and its all left on one line. like this, after the first ;?>"

                                                                                               

          <option value="<?php echo $row_Recordset1['incometype']?>"  <?php if (!(strcmp($row_Recordset1['incometype'], $row_Recordset1['incometype']))) {echo "selected = \"selected\"";} ?>><?php echo $row_Recordset1['incometype']?></option>

          So that looks like a bug in Dreamweaver.

          I have still to find what the problem about more than one slected element is.with the "selected = \"selected\" code, or why it only starts at the second instance:

           

          Usually I find that these errors are caused by other code, so just to prove that this should not be the case, I set up a new page with a static list and a dynamic one. I tested all the code using w3c prior to inserting the dynamic content, and it all checked out. Put the dynamic code into the page and it all fouls up.

          I have been unable to validate any page that has a dynamic list on it, so unless YOU know better, either the Validator has a bug or or the code provided with Dreamweaver has.

          • 2. Re: W3C error with select elements
            whatalotofrubbish Community Member

            Found the problem!

            It is possible to have two files open at the same time, one hiding behind the other - never knew this until today, when I resumed work on the file causing the problem.

            It turned out that two copies of the same file were both open in live view, something which should be impossible I would have thought.

            After Dreamweaver crashed for the tenth time this morning, I  found and closed the other window, and w3c reported no more errors nof the type noted above.

            Dreamweaver also stopped crashing every time that I used the validator.