Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Preventing PHP Tidy from removing an empty tag?

Posted on 2004-10-08
7
Medium Priority
?
567 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 7

Accepted Solution

by:
petoskey-001 earned 2000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

722 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