views:

296

answers:

2

hi

i have following problem - from the server side i get a string like 'hoschi"brother' i want to put this string into a <input value"MYSTRING" />. this results in something like <input value"hoschi" brother" /> which obviously does not work.

any workarounds for this? does escaping the " character with &quot; work within the value tag?

thanks for your help, tobi

+4  A: 

Yes, using &quot; works:

<input type="text" name="last_name" value="&quot;My quote!&quot;" />
Dominic Rodger
+6  A: 

does escaping the " character with " work within the value tag?

Yes. (This isn't a workaround though, it is how HTML is designed to work).

Alternatively, if the value contains only single quotes or only double quotes, then you can use the other to delimit the attribute instead.

David Dorward