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

Help with form field

P: n/a
I Have a form field that needs to have a " character as part of the value.
It's being build by PHP, but I'm missing something. Consider:

$item = '"Houston, TX"';
print '<input type="text" name="City" value="' . $item . '" size="0"
maxlength="' . "$cityLen" . '">

Obviously, this is not going to work as the value clause would be expanded
to

value=""Houston, TX""

How can I have this text field display "Houston, TX" (with the quote
character visible) in the text field.

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

Michael Satterwhite wrote:
I Have a form field that needs to have a " character as part of the value. It's being build by PHP, but I'm missing something. Consider:

$item = '"Houston, TX"';
print '<input type="text" name="City" value="' . $item . '" size="0" maxlength="' . "$cityLen" . '">

Obviously, this is not going to work as the value clause would be expanded to

value=""Houston, TX""


Use the functions htmlentities().

echo '<input type="text" name="City" value="' .
htmlentities($item,ENT_QUOTES);
echo '" size="0" maxlength="' . "$cityLen" . '">;

See <http://www.php.net/manual/en/function.htmlentities.php> for more
information.

Ken

Jul 17 '05 #2

P: n/a
> How can I have this text field display "Houston, TX" (with the quote
character visible) in the text field.

well... have you tried to escape your quote characters (\") ?

--
john
www.realposition.com
Jul 17 '05 #3

P: n/a
Ken Robinson wrote:

Michael Satterwhite wrote:
I Have a form field that needs to have a " character as part of the

value.
It's being build by PHP, but I'm missing something. Consider:

$item = '"Houston, TX"';
print '<input type="text" name="City" value="' . $item . '"

size="0"
maxlength="' . "$cityLen" . '">

Obviously, this is not going to work as the value clause would be

expanded
to

value=""Houston, TX""


Use the functions htmlentities().

echo '<input type="text" name="City" value="' .
htmlentities($item,ENT_QUOTES);
echo '" size="0" maxlength="' . "$cityLen" . '">;

See <http://www.php.net/manual/en/function.htmlentities.php> for more
information.

Ken


Thanks much. That solved the problem.

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.