Link to home
Start Free TrialLog in
Avatar of ianwpugh
ianwpugh

asked on

Preventing PHP Tidy from removing an empty tag?

I'm using PHP Tidy to clean up my HTML before it's sent to the browser.

We have a requirement to have a drop-down box with a blank (space) option, Yes, and No.

The html looks like this:

<select name="fieldname1" class="input">
<option value="" class="input" selected="true"></option>
<option value="Y" class="input">Yes</option>
<option value="N" class="input">No</option>
</select>

After Tidy gets ahold of this it changes it to:

<select name="fieldname1" class="input"><option value="N" class="input">
                                          No
</option><option value="Y" class="input">
                                          Yes
</option></select>

Does anyone have any idea as to how I can prevent Tidy from removing the empty <option> tag?

Thanks in advance,

Ian

ASKER CERTIFIED SOLUTION
Avatar of petoskey-001
petoskey-001

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of minichicken
minichicken

is PHP Tidy a program?
TIDY is a HTML source compressor/formatter put out by the W3C.  
It's written in C and can be found online as "HTML Tidy".  
It's currently hosted on sourceforge at http://tidy.sourceforge.net/

It can take an ugly block of HTML code and turn it into something nicely formatted.

See http://www.w3.org/People/Raggett/tidy/ for some examples
See http://cgi.w3.org/cgi-bin/tidy to use the CGI version on any publicly accessable URL
Good stuff, thanks petoskey-001, will go have a look now and download it and ofcoz use it.... Thanks again :)
NP.  
BTW offtopic but I noticed you have your first 10,000.  For more fun also track you rank and percentage.
For instance in Member Rank (view rank link) it shows your 4408 of 60428 experts so your at 92% of people who have more then 0 points.  It's surprising how fast you climb and just how far apart the real top people are.
Yeah, thanks for the info, I am pretty much new to this EE thing, still finding my way round the place..... surprising ranking results... :)
Avatar of ianwpugh

ASKER

Thanks for the advice.

After looking through the XML that's used to generate the HTML, I found the error was actually in the HTML parser, not Tidy.. Heh.. Thanks anyway :)