• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Getting text to wrap in an input field

Participant ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

I'm working on an imput form.  One text field may have lengthy data.  When the record is displayed, I'd like for it to be shown in several lines as it is on the display records page when I do nothing to format it.  I absolutely cannot get it to show more than will fit in the input field width on one line.  Not very user-friendly!  Any suggestions appreciated.

 

By the way, it seems strange to me that Dreamweaver does not directly support use of databases.  Surely most applications require display from databases, which means the data has to be maintained.  If it's going to be maintained by end users, there needs to be user-friendly means for them to do so.  I'm struggling to provide that.

TOPICS
Code , How to , Server side applications

Views

695

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

LEGEND , Sep 02, 2020 Sep 02, 2020

You use a textarea form field rather than an input form field which is only meant for short amounts of information.

 

Dreamweaver dropped the ball some years back in terms of dynamic database driven websites and wasted their time introducing a lot of redundancy into the program, much which didnt stand the test of time and is now defunct.

 

Those of us that have been around long enough said it would prove to be the final nail in its coffin, we were proved correct. Dreamweaver by todays standards is a

...

Votes

Translate

Translate
Community Expert , Sep 02, 2020 Sep 02, 2020

Before you post to the database it should be written as $_POST['variable'] not $variable.  Doing $variable on the inside of that statement would assume that the variable exists, and instead what you are grabbing is the reference to the $_POST data and not an actual variable that has been defined.

 

If you wanted to uncomplicate this so you don't have to store the HTML in the database and do the join there, you could just look at this from the reverse point of view.  By that, I mean, store your v

...

Votes

Translate

Translate
LEGEND ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

You use a textarea form field rather than an input form field which is only meant for short amounts of information.

 

Dreamweaver dropped the ball some years back in terms of dynamic database driven websites and wasted their time introducing a lot of redundancy into the program, much which didnt stand the test of time and is now defunct.

 

Those of us that have been around long enough said it would prove to be the final nail in its coffin, we were proved correct. Dreamweaver by todays standards is a shadow of its former self and way, way off the pace in terms of modern web development. Although Adobe wont say it, for some reason, Dreamwraver is not their priority.

 

Some time back the road map for Dreamweaver threatened to reintroduce database capabilities but as far as l know thats been put on hold again or at least pushed to the back of the pile, although l believe you can trial whats been introduced to date in the pre-release version.

 

Same old story, while other available products are  being updated on a weekly basis with innovative solutions Dreamweaer continues to fall further behind, unless of course that isnt true in which case can an Adobe employee please explain the situation and the lack of urgency and features.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

I will try textarea again.  I tried once but maybe didn't get syntax right.  If Dreamweaver is getting behind, I'd love to know what other options there are.  Strange that Adobe has so many art-related apps but doesn't care about web design!  my email is on gmail [address removed by moderator as per forum rules.]  I use hostmonster and have been entering data using phpmyadmin for ages.  I want end user to enter data, so I'm struggling.

 

Another problem:  I have a field that displays formatted text.  To display in the input form, I strip the formatting, display a table with the formatting options, & let them choose.  I need to wrap the text in format code before updating.  Using PDO with prepared statements & tokens.  Can't figure out how to reset this field!

 

Thanks for the response!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

Tried input type="textarea" but still shows first part of data in one line.  Do I need to allow more space in table cell?  Tried rows="5" but nothing happened.  I'm inside the paper bag.  Plenty of room onscreen for multiple-line input.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

What are you trying to do. Load some information from your database into a form textarea? Theres no such thing as type="textarea" its just <textarea class="myTextarea"><?php echo $row['content']; ?></textarea>

 

In reference to your other issue, you should never try and load html formatted text into a form input field, that is not what an input form field is used for. You load html formatted text into a form textarea then use a text editor, something like 'ckeditor' to turn the textarea into an area which functions like a word processing programme, allowing the end user to format the text by choosing html tags before the formatted information is pushed to the database and then onto your website page.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

I'm not loading formatted text into an input.  I take a data field containing <span class="RedHdr">Sunday, June 15</span> and display it in TWO input fields.  One is RedHdr, the other is Sunday, June 15.  But to update the record, let's say someone changes the date or changes the color.  I need to wrap it up again so I post <span class="LgGreenHdr">Thursday, August 16</span>.  I can't figure out how to do that.  I can get the variable just fine, but when I post using tokens I don't seem able to use a variable name instead of the field name, example $_POST[$variable].  I also can't directly set Homepage_text['p_heading'] = $variable.  Is there a way to do this?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

I think this is where you need to investigate ckeditor. Once applied to a form text area it allows for a color picker to be added. I think the color picker must be updatable to be able to include a specific pallet of html colors, so in effect once applied via 'ckeditor' your span becomes.

 

<span style="#78f589;">Thursday, August 16</span>.

 

Rather than:

 

<span class="LgGreenHdr">Thursday, August 16</span>.

 

Link:

https://ckeditor.com/cke4/addon/colorbutton

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

I don't need to specify #900 for RedHdr since I have define RedHdr (and all the others I'm using) in a css include file.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

Before you post to the database it should be written as $_POST['variable'] not $variable.  Doing $variable on the inside of that statement would assume that the variable exists, and instead what you are grabbing is the reference to the $_POST data and not an actual variable that has been defined.

 

If you wanted to uncomplicate this so you don't have to store the HTML in the database and do the join there, you could just look at this from the reverse point of view.  By that, I mean, store your values spanClass and date as 2 fields.  Then when you need to print the span on page include the variables then.  As an example:

 

echo "<span class='".$array['spanClass']."'>".$array['dateVal']."</span>";

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

That would certainly do it.  It would mean changing a lot of code that reads & displays the data, after changing the data table.  I had hoped there would be an easier way.  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

I don't know how to get the new value of p_heading to be $p_heading.  If I say $sql = 'UPDATE Homepage_text SET textpage=?, h_date=?, h_seq=?, h_col=?, p_heading=$pheading, p_text=?, h_hide=?, Desk_mob=? WHERE home_key=?';  I get error because prepare & update stmts don't have same number of tokens.  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

Thats because the variable $p_heading needs to go with your other $_POSTs, possibly like below. I dont use prepared statements so its not a familar workflow for me.

 

$stmt->execute(array($_POST['textpage'], $_POST['h_date'], $_POST['h_seq'], $_POST['h_col'], '$p_heading',

 

BUT theres something wrong here because youre saying IF ($headstyle != '') is NOT empty $p_heading = "blah blah" - so if $headstyle IS empty what is this doing in your update query $_POST['p_heading'] as it would be empty, right if it relates to $p_heading in any way?????

 

if you want to keep $_POST['p_heading'] in your update query for a reason which I cant see then you might have to do an if/else statement.

 

 

if ($headstyle != '')
{
$p_heading="<span class=".$headstyle.">".$headtext."</span>";

Run the update statement to include the variable '$p_heading' in the prepared statement query instead of $_POST['p_heading']
}

else {

Run the update statement which includes $_POST['p_heading']

}

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 12, 2020 Sep 12, 2020

Copy link to clipboard

Copied

LATEST

Thanks - great suggestion!  I haven't done it yet because my routines are working, but it's a good solution and I will implement it and appreciate the idea.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

This is my update code:  I don't know how to get datafield p_heading set to $p_heading.

 

if (isset($_POST['update']))
{
# re-format heading to use style
if ($headstyle != '')
  {
    $p_heading="<span class=".$headstyle.">".$headtext."</span>";
  }
#Continue with update
$sql = 'UPDATE Homepage_text SET textpage=?, h_date=?, h_seq=?, h_col=?, p_heading=?, p_text=?, h_hide=?, Desk_mob=? WHERE home_key=?';
$stmt=$sainttim->prepare($sql);
$stmt->execute(array($_POST['textpage'], $_POST['h_date'], $_POST['h_seq'], $_POST['h_col'], $_POST['p_heading'], $_POST['p_text'], $_POST['h_hide'], $_POST['Desk_mob'], $_POST['home_key']));
$done=$stmt->rowCount();

if ( !$done)
{
$error = $stmt->errorInfo();
if (isset($error[2]))
{
$error = $error[2];
}
} /*  not done */
header('Location: DisplayText.php');

exit;
} /* if isset POST */

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

But how have you defined class "myTextarea"???

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 12, 2020 Sep 12, 2020

Copy link to clipboard

Copied

Thanks!  I tried input type="textarea" without success and then you told me it was not input but <textarea> - again I tried without success.  Finally came across a note in Dave Powers' book that said you don't use value= but put the value between the opening & closing textarea tags.  SUCCESS!  Thanks to all the tech angels who help the rest of us!

 

I didn't have any luck trying to split my p_heading for update & then combining before writing to the database.  I'll keep trying but I've got my routines working & can give some thought to splitting the fields and then combining before display as Ben_M advised.  Means a good bit of code editing but is a  cleaner, more elegant solution.  More work while loading which would have slowed things down at one time, but now is no problem.  Memory & chip speed solves lots of problem!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

DW used to have some basic database functionality, but it was removed from the program several versions ago. Adobe chose removal over rewriting the code produced to modern standards.

Adobe has said they will be reintroducing that functionality, but just recently announced it is on hold until other issues are worked out first.

In the mean time, there are paid third party extensions available from WebAssist and DMXZone that can do it, or obsiously, writing the code by hand.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

#1 Below is a <textarea> field for a product's short description and a 2nd one for the long description. Notice the first has a character limit.   Short descriptions appear on the summary page where space is limited.  Long descriptions appear on the details page where space is not limited.  MySQL database fields are programmed accordingly.

 

CMS FORM MARKUP:

<label for="SHORTDESC">SHORTDESC</label>
<textarea name="SHORTDESC" maxlength="255" required id="SHORTDESC" type="textarea" placeholder="255 characters max, no smart quotes" onkeyup="this.value=this.value.replace('’','')" value=""></textarea>


<label for="LONGDESC">LONGDESC</label>
<textarea id="LONGDESC" type="textarea" placeholder="HTML code is OK, no smart quotes" required name="LONGDESC" onkeyup="this.value=this.value.replace('’','')" value=""></textarea>

 

SQL FIELD TYPE:

SHORTDESC = varchar(255)

LONGDESC = text

 

#2 Dreamweaver is merely a front end coding tool.  What you bring to the backend depends on you. Building a custom CMS is an advanced project that's not suited to everyone.  Server-side or client-side code used to query databases varies a lot by hosting and personal preferences.  There's no one-size fits all.  A boxed CMS solution like Perch CMS might work for this project.  Or you could go in an entirely different direction and build your app with 3rd party extensions (DMX Zone or Web Assist) or use frameworks like Angular & Node.js.  Your choice.

 

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

My code for this field:

<td><input type="textarea" name="p_text" size="62" value="<?php echo htmlentities($p_text, ENT_COMPAT, 'utf-8'); ?>"></td>

I don't understand the placeholder or onkeyup.  I'm using html & php.  Everything I know is from manuals & some video tutorials.  This forum is my only access to other developers.   There's clearly a LOT I don't know.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

There's nothing exotic about my code.

 

Placeholder = HTML5 forms attribute.  It shows users a hint in the field.

https://www.w3schools.com/tags/att_input_placeholder.asp

 

onkeyup = JavaScript to strip out possible curly quotes before they ever reach the database.  I did this because some users copy & paste formatted content from Word which can mess things up big time.

onkeyup="this.value=this.value.replace('’','')" 

 

 

 

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

On the page where I display the records, the data wraps and some text fields cover 11-12 lines.  The data is in a table and the only thing I've specified is  <td><?php echo $text[i]; ?></td>.

 

The problem I'm having is when I've selected a record to edit and we've gone to an input routine.  In THAT table, the text is displayed on one line - as much as will fit in the space, so you have to scroll through to see the total field contents.  How do I get that to display multi-line?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

From what l can gather you are trying to edit multiple lines of text in a text form field rather than a form textarea field. I dont get what you mean by THAT table. You dont use tables, <td></td> when editing, you use form fields and the appropriate one for multiple lines of text is the textarea field in association with an html editor to force the textarea to act like a Word processing area so you can format the text by choosing options from a menu bar.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines