Solved

Preventing PHP Tidy from removing an empty tag?

Posted on 2004-10-08
7
504 Views
Last Modified: 2008-02-07
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

0
Comment
Question by:ianwpugh
  • 3
  • 3
7 Comments
 
LVL 7

Accepted Solution

by:
petoskey-001 earned 500 total points
ID: 12258646
don't leave it blank, use the non-breaking space instead ( &nbsp; )


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

This will give you what you want
0
 
LVL 12

Expert Comment

by:minichicken
ID: 12258679
is PHP Tidy a program?
0
 
LVL 7

Expert Comment

by:petoskey-001
ID: 12258749
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
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 12

Expert Comment

by:minichicken
ID: 12258864
Good stuff, thanks petoskey-001, will go have a look now and download it and ofcoz use it.... Thanks again :)
0
 
LVL 7

Expert Comment

by:petoskey-001
ID: 12259756
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.
0
 
LVL 12

Expert Comment

by:minichicken
ID: 12259979
Yeah, thanks for the info, I am pretty much new to this EE thing, still finding my way round the place..... surprising ranking results... :)
0
 

Author Comment

by:ianwpugh
ID: 12286459
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 :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now