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.

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

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序