473,386 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Help with form field

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
3 1385

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
> 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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Mike | last post by:
I've been trying for the past week to put a simple code together. I have done a LOT of searching, found scripts showing the functions I would like to use, however when I mix them it all goes wrong,...
5
by: Mike | last post by:
I'm using a script provided by e-mailanywhere, it's a little too big for me. There's 1 text field and 1 password field in a form. OnSubmit, I would like both fields to be validated to look for...
2
by: qsweetbee | last post by:
I have a form(fAddUsers) in my database. It is continue form for data entry. Some fields are required fields. Some are optional fields. There is 1 particular filed(TokenExpirationDate)on the form...
3
by: Earthling | last post by:
Any help would be appreciated to solve the following simple problem that I will describe. *** There is a form called "red chocolate form". The form has a particular subform field that has a...
8
by: Steph | last post by:
Hi. I'm very new to MS Access and have been presented with an Access database of contacts by my employer. I am trying to redesign the main form of the database so that a button entitled...
2
by: Chris Millar | last post by:
Can anyone help me on converting this vb asp page to C#, thanks in advance. chris. <!DOCTYPE HTML PUBLIC "-//W3C//Dtd HTML 4.0 transitional//EN"> <%...
3
by: cappelquist | last post by:
I have a small Task List / Project Management / Time Management app I'm building for my own use. Any "Getting Things Done" (GTD) users out there? I want a main form that has a large List Box on...
10
by: 60325 | last post by:
This is the page where I collect the data in drop-down boxes with values of 1-10 and send it to a submitted page to do calculations. Example: Employee1 TeamScore(1-10) Employee2 ...
1
by: mr k | last post by:
Hi, I wanted to use mail merge with forms but Text form fields are not retained during mail merge in Word, I got the code from Microsoft but it doesn't remember the text form field options such as...
10
by: dkyadav80 | last post by:
<html> /// here what shoud be java script for: ->when script run then not display all input text field only display selection field. ->when user select other value for institute only this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.