Lewis
Lewis

Reputation: 622

wordpress php issue echoing html elements to page

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] 

Upvotes: 0

Views: 142

Answers (1)

Marc B
Marc B

Reputation: 360762

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.

Upvotes: 1

Related Questions