By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,625 Members | 2,235 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,625 IT Pros & Developers. It's quick & easy.

Proper code for input tag

P: n/a
Hello All,

I have an input tag that I am populating with data from a database.
My problem is the following:

The data in the database that contains single and double quotes.

What do I do?

Currently, I've tried the following...
input type=text name=collName value='Be'er Shmuel Talmudical Academy'
size=35 maxlength=35

But the above code only displays "Be"

I've tried...

input type=text name=collName value="Be'er Shmuel Talmudical Academy"
size=35 maxlength=35

But that works okay for single quotes, but for double quotes I have
the same problem...

How do I fix this? Should I just stick with double quotes and then is
it possible to escape the double quotes that are in the field?

Thanks!
--
Nathan
Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On 26 Jul 2004 19:09:39 -0700, Nathan Given <ng****@hotmail.com> wrote:
Hello All,

I have an input tag that I am populating with data from a database.
My problem is the following:

The data in the database that contains single and double quotes.

What do I do?

Currently, I've tried the following...
input type=text name=collName value='Be'er Shmuel Talmudical Academy'
size=35 maxlength=35

But the above code only displays "Be"

I've tried...

input type=text name=collName value="Be'er Shmuel Talmudical Academy"
size=35 maxlength=35

But that works okay for single quotes, but for double quotes I have
the same problem...

How do I fix this? Should I just stick with double quotes and then is
it possible to escape the double quotes that are in the field?

Thanks!
--
Nathan


Replace ' with ' and " with ", and escape the & instead when
processing the data. A little simpler exercise than escaping all the
characters you can't use in a script.
Jul 20 '05 #2

P: n/a
Nathan Given wrote:
I have an input tag that I am populating with data from a database.
My problem is the following:

The data in the database that contains single and double quotes.

input type=text name=collName value='Be'er Shmuel Talmudical
Academy' size=35 maxlength=35

But the above code only displays "Be"

How do I fix this? Should I just stick with double quotes and then
is it possible to escape the double quotes that are in the field?


Depends on the scripting language and your database. It is probably
possible. You'd get more useful help by asking how to do this in a
group dedicated to the particular language you use. If it's PHP,
perhaps this will help:

http://us3.php.net/htmlentities

(aside: why do the php folks insist on several different domains that
hold the same info? I seem to get redirected to a us3 or de subdomain
depending on I don't know what. The phase of the moon?)

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 20 '05 #3

P: n/a
Nathan Given wrote:

input type=text name=collName value='Be'er Shmuel Talmudical Academy'
size=35 maxlength=35

But the above code only displays "Be"

Place all the values in double quotes. Convert all double quotes within
the text to "&quot;":

<input type="text" name="collName"
value="Be'er Shmuel Talmudical Academy is &quot;Great!&quot;"
size="35" maxlength="35">

--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Jul 20 '05 #4

P: n/a
In article <10*************@corp.supernews.com>,
Brian <us*****@julietremblay.com.invalid> wrote:
http://us3.php.net/htmlentities

(aside: why do the php folks insist on several different domains that
hold the same info? I seem to get redirected to a us3 or de subdomain
depending on I don't know what. The phase of the moon?)


Load balancing server maybe?

--
Kris
<kr*******@xs4all.netherlands> (nl)
Jul 20 '05 #5

P: n/a
Kris wrote:
Brian wrote:

why do the php folks insist on several different domains that
hold the same info? I seem to get redirected to a us3 or de
subdomain depending on I don't know what.


Load balancing server maybe?


You certainly don't need multiple urls to accomplish that!

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 20 '05 #6

P: n/a
In <f7**************************@posting.google.com >, on 07/26/2004
at 07:09 PM, ng****@hotmail.com (Nathan Given) said:
How do I fix this?


Use charater entities for such situations, e.g.,

'
&acute;
&dquote;

input type=text name=collName value='Be'er Shmuel Talmudical
Academy' size=35 maxlength=35

--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to sp******@library.lspace.org

Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.