dongsu3664 2014-10-02 16:00
浏览 53
已采纳

wordpress php问题回显页面的html元素

I'm having a nightmare with wordpress and PHP as I'm not great with either.

I'm trying to dynamically generate an options menu and I'm using the following lib:

http://loudev.com/

But, the output to the page appears as plain text values of the array I've pulled from my database (this is returned from the getB2BCountSelection(); function)

I've got the lib referenced in my header for the css and js file and jquery referenced etc.

so far as I can tell its simply that my HTML tags are not being written to the page DOM.

Here is an example of the output:

select alldeselect all Abattoir Machinery and Equipment Abattoirs Abrasive Products - Production Of Abrasive Products - Wholesale & Supply Access Equipment Accident Administration & Management Services Accommodation

Any ideas ?

EDIT: I'm running the below PHP and still getting the above issues and non tagged output.

[php]
$row = getB2BCountSelection();
$pages = count($row);
echo '<select id="public-methods" multiple="multiple">';
echo '<a href="#" id="select-all">select all</a>';
echo '<a href="#" id="deselect-all">deselect all</a>';
for ($i = 0; $i < $pages; $i++)
{
    echo "<option value='".$row[$i][0]."'>".$row[$i][0]."</option>";
}
echo '</select>';
[/php] 
  • 写回答

1条回答 默认 最新

  • dq13733519262 2014-10-02 16:09
    关注

    You're NESTING two selects, producing the following (formatted) html:

    <select>
       <a>....</a>
       <a>....</a>
       <select>
    

    Both of your <select> tags have the SAME id, which is illegal - a DOM element ID must be unique across the entire DOM. Beyond that, your HTML is basically invalid. A <select> should not contain ANYTHINg other than <option> or <optgroup> tags. <a> and <li> inside is not valid.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?