Solved

Preventing PHP Tidy from removing an empty tag?

Posted on 2004-10-08
7
552 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 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
WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

635 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