Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Qotes in a Quote

Status
Not open for further replies.

altendew

Programmer
Mar 29, 2005
154
US
Hello.

I current want to-do this.

Code:
<option value="<Site function="loadMe()" />">Load Component</option>

Now the value of the option is
<Site function="loadMe()" />

The only problem is.. it's surrounded by quotes already.. I know I can use single quotes instead of double quotes, but then my html will not be valid, how can I keep double quotes for both?
 
You can not use escape quotes in html.. and I said I do not wish to use signle apostrophe
 
altendew said:
The only problem is.. it's surrounded by quotes already.. I know I can use single quotes instead of double quotes, but then my html will not be valid, how can I keep double quotes for both?
Who said single quotes are not valid html? Did you actually check that statement? I hear that xhtml needs every attribute quoted, but I don't recall requiring it double quoted.
 
All tag attributes, such as <p align="center"> must be enclosed within double quotes. You no longer have the choice of either single or double quotes.
 
That example really looks contrived. Is that the ACTUAL code you're using, or just something you made up for the question you asked?

You can always use &#34; to replace a quote with, then on the page that processes the form information replace that with a regular double quote.

Lee
 
I have it figured out thanks for all your help.
 
So what was the solution?

-kaht

[small]How spicy would you like your chang sauce? Oh man... I have no idea whats goin on right now...[/small]
[banghead]
 
Code:
&gt;Site function=&quot;loadMe()&quot; /&lt;
 
oops here is the correct code.

Code:
&lt;Site function=&quot;loadMe()&quot; /&gt;
 
Just for the sake of completeness, I would like you to comment on the quote you pasted in regards to single quotes and validation. Where did you find that quote and how do you explain the fact that the page I gave was xhtml 1.0 strict valid with all single quotes?
 
I found out that when you find differing information on the W3C site and the other sites regarding the standards, bet on the W3C to be correct.

W3C claims that all attributes need to be quoted, but it never specifies what kind of quotes do they need to be. I suppose someone misinterpreted that requirement and added double to the whole thing. From then on the information started spreading.
 
I've never used single quotes myself, preferring to keep double for HTML and single for JS to help me distinguish the two... but I have seen them used.

If you refer to the XHTML 1.0 specs, it simply says they should be quoted... but it also says XHTML is based around XML and goes on to show this example:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!-- initially, the default namespace is "books" -->
<book xmlns='urn:loc.gov:books'
    xmlns:isbn='urn:ISBN:0-395-36341-6' xml:lang="en" lang="en">
  <title>Cheaper by the Dozen</title>
  <isbn:number>1568491379</isbn:number>
  <notes>
    <!-- make HTML the default namespace for a hypertext commentary -->
    <p xmlns='[URL unfurl="true"]http://www.w3.org/1999/xhtml'>[/URL]
        This is also available <a href="[URL unfurl="true"]http://www.w3.org/">online</a>.[/URL]
    </p>
  </notes>
</book>

which clearly shows single quotes around attributes.

I think the original answer from Jeff was spot on, and don't think you'll get any problems with it:

Code:
<option value='<Site function="loadMe()" />'>Load Component</option>

However - you SHOULD escape the < and > characters:

Code:
<option value='&lt;Site function="loadMe()" /&gt;'>Load Component</option>

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top