 |

11-29-2007, 11:19 AM
|
|
WebProWorld Member
|
|
Join Date: Nov 2006
Posts: 72
|
|
Truncated text box - PHP
Hello everyone,
Having a problem with one of my text boxes and the displayed value being truncated.
<input name="Comments" id="Comments" type="text" value="<?php echo htmlspecialchars($row_orderComments['PPassValue']); ?>" />
Text is displayed right up to the first space character and then nothing...
I have several other text boxes on the same page with no issues so I'm a bit perplexed as to why this one is being truncated.
I added the htmlspecialchars after doing some reading but no joy. When I view the source of the page, the entire value is written correctly in the value= field but its not displaying in the text box. There are no size or max char limitations. I've tested it with both fields that may have special characters and one's without any special character but still nothing.
I've also created it so it's not in a form element and it displays just fine. It's just when it's in a text box.
*scratches head*
Any help is appreciated.
Thanks,
DaK
|

11-29-2007, 01:05 PM
|
 |
Moderator
|
|
Join Date: Jun 2006
Location: United States
Posts: 1,647
|
|
Re: Truncated text box - PHP
Try this: <input name="Comments" id="Comments" type="text" value="<?=htmlspecialchars($row_orderComments['PPassValue'])?>" /> This will remove formatting issues that may result from any PHP syntax. Also, make absolutely sure that the first quotation mark is in the position shown in your sample, and that the htmlspecialchars function is not replacing spaces with
|

11-29-2007, 04:47 PM
|
|
WebProWorld Member
|
|
Join Date: Nov 2006
Posts: 72
|
|
Re: Truncated text box - PHP
Thanks for responding Wige but no joy. Not sure what is going on here.
DaK
|

11-29-2007, 05:26 PM
|
 |
Moderator
|
|
Join Date: Jun 2006
Location: United States
Posts: 1,647
|
|
Re: Truncated text box - PHP
Can you post what the tag looks like when you view source on the rendered page?
|

11-30-2007, 10:43 AM
|
|
WebProWorld Member
|
|
Join Date: Nov 2006
Posts: 72
|
|
Re: Truncated text box - PHP
Sure,
<td><input name="Comments" id="Comments" type="text" value="ph-LCM
please cut pole 5ft and two pieces of 86 , 3 pieces total." /></td>
In the text box on the page itself, you only see "ph-LCM".
Thanks,
DaK
|

11-30-2007, 11:33 AM
|
 |
Moderator
|
|
Join Date: Jun 2006
Location: United States
Posts: 1,647
|
|
Re: Truncated text box - PHP
My theory is that a newline is being added somehow, possibly by the special characters function (changing a br to a newline?) or by whatever is putting the value into/getting the value from the database. Text fields do not display anything after a \n or \r, unlike text areas.
|

11-30-2007, 11:36 AM
|
|
WebProWorld Member
|
|
Join Date: Nov 2006
Posts: 72
|
|
Re: Truncated text box - PHP
That is very possible and would probably explain why the other text boxes work fine since there is no possibility of there being line breaks.
Is there a quick way I can sanatize for the line breaks? I'm not that good with regular expressions.
Thanks,
DaK
|

11-30-2007, 11:48 AM
|
 |
Moderator
|
|
Join Date: Jun 2006
Location: United States
Posts: 1,647
|
|
Re: Truncated text box - PHP
PHP Code:
$row_orderComments['PPassValue'] = ereg_replace("\n", '', $row_orderComments['PPassValue']); $row_orderComments['PPassValue'] = ereg_replace("\r", '', $row_orderComments['PPassValue']);
This will remove both \n and \r. Some systems do line returns with both characters (\r\n) so you need to sanitize for both.
|

11-30-2007, 12:29 PM
|
|
WebProWorld Member
|
|
Join Date: Nov 2006
Posts: 72
|
|
Re: Truncated text box - PHP
Bingo!
Works like a charm. Thanks for bailing me out Wige!
DaK
|

12-06-2007, 04:18 AM
|
|
WebProWorld New Member
|
|
Join Date: Dec 2007
Posts: 4
|
|
Re: Truncated text box - PHP
Congrats for you success.
Another variant is to use Css or dhtml for your needs.
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|