We have a note file that we are loading up to a text area on a PUI screen. The note file can consist of multiple line records with a text field of 50 characters. When I load the data to the text area, I am concatenating the hex code for a line feed to the end of each text field so that the text area lines up correctly with how the data was stored. The hex character I am using for a line feed is X'25'.
When I update the file from the text area I strip out the line feeds so as not to get them back into the file on the iSeries.
That all works fine. We have created button connected to a java script function that will take the user highlighted portion of the text area and strip out all formatting so the user can then place the spacing and line feeds from a fresh start.
It seems as if the line feeds are not being removed using the java script function and my java expert here was wondering how PUI would store the line feeds in the text area.
His function uses this the following to strip out out formatting:
selection.text = selection.text.replace( /(\r\n|\r|\n)+/g, " ");
The function will actually re-format the text area correctly to the naked eye but when I start reading through the text area data in my RPG in debug I can still see the line feeds in the string even if no more formatting has been done.
We want the line feeds to be stripped out so the user can reformat anew.
Hope this makes sense and someone can give us a hand.
Thanks!
Text Area and Line Feeds
-
- Experienced User
- Posts: 116
- Joined: Wed Sep 05, 2012 11:14 am
- First Name: Eric
- Last Name: Hill
- Company Name: Integrated Corporate Solutions
- Phone: 256-760-8239
- Address 1: 501 S Wood Avenue
- City: Florence
- State / Province: Alabama
- Zip / Postal Code: 35630
- Country: United States
- Contact:
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Text Area and Line Feeds
Hmmm... normally a text area's data is in a field named "value", so I'm not sure what "selection.text" is referring to in this example... maybe it's something you created internally?
But, anyway, my guess is that you are changing the value on the web page by manipulating the DOM directly. This works, but there is some additional information that PUI is keeping track of under the covers that won't get updated this way. I believe that PUI keeps track of whether an element has been changed, and only submits it back to the RPG if it has changed -- this keeps network traffic at a minimum.
But if you change it directly (by changing the "value" property of the text area directly) it won't change PUI's flag that keeps track of whether the value has changed or not, so it won't get submitted back to the RPG program.
The solution is to use PUI's changElementValue() API to change the data. For example, your onclick routine might look like this:
The first line retrieves the DOM object for the textarea. (This assumes that the id of the object is "TextArea1", if not, please change the code accordingly.)
The second line replaces all CRLF or CR or LF with a blank.
The third line calls the PUI changeElementValue routine, which will mark the data as changed so that it gets submitted back to the server as expected.
Make sense?
But, anyway, my guess is that you are changing the value on the web page by manipulating the DOM directly. This works, but there is some additional information that PUI is keeping track of under the covers that won't get updated this way. I believe that PUI keeps track of whether an element has been changed, and only submits it back to the RPG if it has changed -- this keeps network traffic at a minimum.
But if you change it directly (by changing the "value" property of the text area directly) it won't change PUI's flag that keeps track of whether the value has changed or not, so it won't get submitted back to the RPG program.
The solution is to use PUI's changElementValue() API to change the data. For example, your onclick routine might look like this:
Code: Select all
var myText = getObj("TextArea1");
myText.value = myText.value.replace( /(\r\n|\r|\n)+/g, " ");
changeElementValue("TextArea1", myText.value);
The second line replaces all CRLF or CR or LF with a blank.
The third line calls the PUI changeElementValue routine, which will mark the data as changed so that it gets submitted back to the server as expected.
Make sense?
-
- Experienced User
- Posts: 116
- Joined: Wed Sep 05, 2012 11:14 am
- First Name: Eric
- Last Name: Hill
- Company Name: Integrated Corporate Solutions
- Phone: 256-760-8239
- Address 1: 501 S Wood Avenue
- City: Florence
- State / Province: Alabama
- Zip / Postal Code: 35630
- Country: United States
- Contact:
Re: Text Area and Line Feeds
Yes it does, Scott. Will try that first thing Monday morning.
Thanks!!!!
Thanks!!!!
Who is online
Users browsing this forum: No registered users and 4 guests