Should be easy...

How do I get a double quote AND a single quote to appear as a value in a text field?  What I want is to have the string:
"Mrs. O'Connel"
appear in a text box.  (Oversimplification, but it gets across what I need.)  I've tried:
<input type="text" value='"Mrs. O''Connel"'>
but I just get "Mrs.O as a value.  How do I get the literals in there????

allie
LVL 2
allieAsked:
Who is Participating?
 
COBOLdinosaurCommented:
You have to escape the quotes and appostrophe this way:
<input type="text" value=' &#34;Mrs. O&#39;Connel&#34;'>


Cd&
0
 
ahoffmannCommented:
&#22; or %22 does not work with all browsers :-(

<input type=text value="O'Connel">
<input type=text value='O"Connel'>

but both mixed only if your browser supports HTML entitities in TAG attributes.
Probably you can do it with JavaScript ..
0
 
knightEknightCommented:
I got it to work with back-ticks in IE ... i don't know if this will work in all browsers:

value=`"O'Connel"`
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
brunoCommented:
any way to do it XHTML compliant where the attribute is quoted propery?  

there should be, as that will soon be the standard...


BRUNO
0
 
allieAuthor Commented:
COBOLdinosaur and ahoffmann-

Excellent!  The "&#34" seems to be working!!  I'm a little concerned though about ahoffmann's comment that this may not work for all browsers... I'm using IE5, so which one's might it not work for?  If it's Netscape or IE6, that might be a problem.  If it's Opera or something like that I don't care as much... any info on how to find out what browsers use which escape codes??


Oh and BTW ahoffmann, I need to have both double and single quotes in the same field, so your example wouldn't work...  thanks though!

allie
0
 
allieAuthor Commented:
Oh yeah, also BTW, I saw in my HTML book that the escape sequence for the double quote (at least in URL encoding) is %22... but that didn't work at all here.  I had to use &#34 instead of &#22 or I didn't get the double quote (some other character appeared instead).  Wierd, but I thought I'd point it out...

allie
0
 
COBOLdinosaurCommented:
I'm not sure which browsers will not support the escape characters.  

It is support by any browser that supports HTML3.2 or higher.

Specific browser support is:

IE since version 1
NS since version 1
opera since version 2.1

Based on references from WWw.blooberry.com.

I have not run across any browser that does not support the format, but there are a lot of fringe browsers around.

The complete list of support characters can be found at:
http://www.cwru.edu/hel/interHTML/examples/isolist0.html

Cd&
0
 
COBOLdinosaurCommented:
Oops.  Typo in the link it should be:

http://www.cwru.edu/help/interHTML/examples/isolist0.html

Cd&
0
 
lexxwernCommented:
what happened to the good old days of the \ from the c++ legacy.
0
 
ahoffmannCommented:
didn't dig deep (oops: nice acronym DDD) into the entitity problem, but know from experiance that following browsers do not what w3c recommends, or you expect:
   arachne, lynx, w3m, Netscape 4.x 6.x, Opera 4.x 5.x 6.x (not shure about 3.x), Konqueror 1.x 2.x, Mozilla 0.9.x

As I understand w3c docs, it's up to the browser how to implement these entitities in tag attributes, and that it is a CSS feature not HTML. But let me know if I missed some docs ;-)

I'm also suprised that some of the browsers behave strange (Netscape 6.x, Opera), but that's probably 'cause I only use "default" installations, and have not fiddled around with the browser's "user.css".

Hope this helps a bit.

BTW, didn't find a "Browser-Checks" list which have a check for this behaviour.
0
 
COBOLdinosaurCommented:
Support for major browsers show here.  A site which most who use it find very reliabel on cross-browser issues:

http://www.blooberry.com/indexdot/html/tagpages/c/charents.htm

Related Sites
Official References
http://www.rfc-editor.org/rfc/rfc1866.txt 
RFC 1866: The HTML 2.0 specification (plain text.) Appendix contains Character Entity table.
http://www.w3.org/MarkUp/html-spec/html-spec13.html 
The web version of the HTML 2.0 (RFC 1866) Character Entity table
http://www.w3.org/MarkUp/Wilbur/ 
The HTML 3.2 (Wilbur) recommendation
[This includes all character entities listed in HTML 2.0 plus new named entities covering the ISO 8859-1 120-191 range.]
http://www.w3.org/TR/REC-html40/ 
The HTML 4.0 Recommendation
[Includes new Unicode character entities]
http://www.w3.org/International/O-HTML.html 
The W3C HTML Internationalization area
http://unicode.org <http://www.unicode.org
The Unicode Consortium site

Other Related Links

http://www.ramsch.org/martin/uni/fmi-hp/iso8859-1.html 
Excellent resource with good pointers on ISO-8859 issues
http://ppewww.ph.gla.ac.uk/%7Eflavell/iso8859/iso8859-pointers.html
Alan Flavell's excellent document of pointers to information about ISO-8859
http://ppewww.ph.gla.ac.uk/%7Eflavell/iso8859/character-faq.txt
Alan Flavell's brief FAQ document regarding ISO-8859 issues in HTML
http://www.bbsinc.com/iso8859.html 
Kevin J Brewer's page with MANY links regarding character set issues.

Cd&

0
 
COBOLdinosaurCommented:
If you have seen it in Netscrap 6, then you are seeing a buggy version.  You might want to check bugzilla to see what is documented.  There were a lot of presentation problems associated with 6.  Tens of thousands of bug reports.

Cd&
0
 
allieAuthor Commented:
COBOLdinosaur-

You don't seem like a dinosaur to me!  ;)  Thanks for the help, and the links - now if someone comes back to me and says it doesn't work in their browser I can find out why!

Thanks everyone!

allie
0
 
COBOLdinosaurCommented:
Glad we could help.  Thanks for the A. :^)

Cd&
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.