Setting a value to Html form field

B

boss

Hi,

I am trying to set a hidden form value.
When the value contains ' the page is giving some unwanted results.
Please let me know, how to handle this

Html code for your reference:
<input type='hidden' name='hiddenValue' vaule='that's it'/>


Thanks
Anand
 
M

+mrcakey

boss said:
Hi,

I am trying to set a hidden form value.
When the value contains ' the page is giving some unwanted results.
Please let me know, how to handle this

Html code for your reference:
<input type='hidden' name='hiddenValue' vaule='that's it'/>

Pretend you're a computer. Read through your code and ask yourself where
your computer thinks the values for your attributes begin and end.
 
J

Jukka K. Korpela

boss said:
I am trying to set a hidden form value.
When the value contains ' the page is giving some unwanted results.
Please let me know, how to handle this

Html code for your reference:
<input type='hidden' name='hiddenValue' vaule='that's it'/>

This time the fragment is sufficient for analysis, though not for solving
other problems (like "is it really a good idea to use hidden fields in your
case?"). The URL would still have been useful. For example, it often happens
that when you type or copy HTML markup into a message, some nasty software
transmogrifies it so that it isn't exactly the original.

Actually, the attribute name vaule is misspelled in your snippet. Your
actual page probably contains the correct spelling, value.

The problem is that the apostrophe ' is not allowed inside the quoted
attribute value when the apostrophe is used for quoting the string, as a
delimiter. You can avoid the problem in several ways, e.g. using quotation
mark as delimiter:
value="that's it"
or using a character reference,
value='that's it'
or maybe the typographically correct curly apostrophe (assuming you really
want to include the natural-language expression you gave as example), either
as such (I won't try it here because Usenet is not safe for non-ASCII,
though the web mostly is, properly used) or as a character reference:
value='that’s it'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,263
Messages
2,571,064
Members
48,769
Latest member
Clifft

Latest Threads

Top