Focal Point
[SOLVED] Capture multiple entries separated by CR or semi colon from text area

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/3447075436

November 07, 2013, 03:56 PM
paulux99
[SOLVED] Capture multiple entries separated by CR or semi colon from text area
Since my other post http://forums.informationbuild...1057331/m/7017015436 has been corrupted, I created this post with a solution that worked for me.
This works up to about 900 records (25 Characters) in my scenario. I use one of the suggestions from this post:
http://forums.informationbuild...447009495#7447009495

HTML page coding
<form method=post action="/ibi_apps/WFServlet" METHOD="post">
<input NAME="IBIF_ex" VALUE="multipart" TYPE="hidden">
<TEXTAREA NAME="PN" COLS=20 ROWS=20></TEXTAREA>


which calls this fex file: multipart

-REPEAT :ENDREPEAT1 FOR &I FROM 1 TO 2000

-SET &TOKEN = GETTOK(&PN,&PN.LENGTH,&I,';',25,'A25');

-IF (&TOKEN EQ '') GOTO :EXITREPEAT1 ;

-SET &INPUT.&I = LJUST(25,&TOKEN,'A25');
-:ENDREPEAT1
-:EXITREPEAT1
-*
-SET &COUNT_INPUTS = &I - 1 ;
-SET &J = 1 ;
-SET &WHEREIN = '''' | &INPUT.&J | '''';
-*
-REPEAT :ENDREPEAT2 FOR &J FROM 2 TO &COUNT_INPUTS
-SET &WHEREIN = &WHEREIN | ' OR ''' | &INPUT.&J | '''';
-:ENDREPEAT2

TABLE FILE PARTINFO
PRINT PART
WHERE PART CONTAINS &WHEREIN;
ON TABLE PCHOLD FORMAT EXCEL
END

This message has been edited. Last edited by: paulux99,
November 11, 2013, 11:07 AM
paulux99
I have not found an exact solution where I could use CR or LF in a text area instead of semi colon ;
Any suggestions?

This message has been edited. Last edited by: paulux99,
November 11, 2013, 03:27 PM
nd
If you can't get the textarea to do multiples. (and you should try adding multiple="multiple" operator="OR" to the textarea tag), then stripping carriage returns and line feeds is more simply done with javascript. By the time they get to the fex, they're already tossed out.

Here's an example that looks for a cr/lf combo following a word (the \b in the search string used by the .replace() method). Making sure it follows a word means that if your users enter blank lines or lines that contain only spaces you won't end up with extra ORs.

This is all handcoded. Again, if you've got HTML composer and all of its hooks in the HTML, try opening the file in a text editor and looking for the textarea tag and telling it that it's a multiple.

<html>
<script type=text/javascript id=makeparam>
	function adddelimiter(visibleid,hiddenid){
		var undelimited=document.getElementById(visibleid).value;
		document.getElementById(hiddenid).value=undelimited.replace(/\r\n\b/g, ' OR ');
	}
</script>
<body>
	<FORM id=form1 name=form1 action=/ibi_apps/WFServlet method="get">
		<input type='hidden' name='IBIMR_action' value="MR_RUN_FEX">
        <input type='hidden' name='IBIMR_sub_action' value="MR_STD_REPORT">
		<input type='hidden' name='IBIMR_flags' value="">
		<input type='hidden' name=IBIMR_domain value=mydomain/mydomain.htm > 
		<input type='hidden' name=IBIMR_folder value=#myfolder> 
		<input type='hidden' name=IBIMR_fex value=app/parts.fex> 
		<input type='hidden' name=ibif_ex value=app/parts.fex> 

		<textarea NAME=PN1 multiple id=PN1 cols=20 rows=20; ></textarea>
		<input type=hidden name=PN id=PN cols=20 width=20>
		<p>
		<input type=submit  onclick=adddelimiter('PN1','PN') >
	</FORM>
</body>
</html> 



WF: WebFocus 7.7.03
Data: Oracle, MSSQL, DB2
OS: Windows
Output: HTML/AHTML,PDF,EXL2K FORMULA, COMT
November 11, 2013, 04:15 PM
paulux99
Nd,
thanks for your suggestion, I am able to display: PART1 OR PART2 R OR PART3=1 OR PART4+1
but I am missing the single quote ' around the record so desired outcome would be to surround with single quote
WHERE PARTNO CONTAINS 'PART1' OR 'PART2 R' OR 'PART3=1' OR 'PART4+1'.
Assuming the js would need to be updated? or update parts.fex?
November 11, 2013, 05:52 PM
nd
something like
'\''  + \undelimited.replace(/\r\n\b/g, '\' OR \'') + '\'' 


should do it.

This message has been edited. Last edited by: nd,


WF: WebFocus 7.7.03
Data: Oracle, MSSQL, DB2
OS: Windows
Output: HTML/AHTML,PDF,EXL2K FORMULA, COMT
November 12, 2013, 01:52 AM
Dave
Paulux,

it should work without additional coding.

FEX
TABLE FILE CAR
	SUM SALES
	BY CAR
WHERE CAR EQ &CAR.(OR()).Select cars.;
END


Save it.

Now make a new HTML.
Add a form.
Link the 'run' button to above fex.

Select "Textarea" as input type.

Check the properties of the textarea.

Multiple should already be set to "Multiple".

Only thing you have to do is set : "Multiple: Add quotes" to "Yes".

Good luck.
Dave


_____________________
WF: 8.0.0.9 > going 8.2.0.5
November 12, 2013, 09:36 AM
paulux99
Nd,
Thanks for update with single quote, when I update js coding with
document.getElementById(hiddenid).value='\''  + undelimited.replace(/\r\n\b/g, '\' OR \'') + '\'' ;
or this code
document.getElementById(hiddenid).value="'" + undelimited.replace(/\r\n\b/g, '\' OR \'') + "'" 

I get the error: "The website declined to show this webpage HTTP 403"
Both ie or firefox do not like the extra coding on single quote from js. I tried to lookup for a solution, I did not find anything.

Dave,
Thanks for suggestion, I am trying to copy and paste a single column of records with CR in excel (up to 1000 records) to a text area but maybe I can use some part of your suggested code.

This message has been edited. Last edited by: paulux99,
November 13, 2013, 10:57 AM
nd
403 is a web server error, and if you're curious, you should look into its logs to see just what it means.

I can offer a tidied, better tested version of the original javasctipt.
 
function adddelimiter(visibleid,hiddenid){
     var undelimited=document.getElementById(visibleid).value;
     var orvalue='\'' + ' OR ' + '\'';
     var newvalue='\'' + undelimited.replace(/\r\n|\r|\n\b/g, orvalue) + '\'';
     document.getElementById(hiddenid).value=newvalue;
	} 


You might look into codeacademy

Which offers free, interactive online lessons on several web concepts--include HTML, javascript, and jquery.


WF: WebFocus 7.7.03
Data: Oracle, MSSQL, DB2
OS: Windows
Output: HTML/AHTML,PDF,EXL2K FORMULA, COMT
November 13, 2013, 01:01 PM
paulux99
Nd, thanks for update.

Using your original code, I have replaced ' OR ' with ';' . This will work.
document.getElementById(hiddenid).value=undelimited.replace(/\r\n\b/g, ';');


then I use my original code in beginning of my post (fex: multipart). also, due to ie limitation on url, use METHOD="post" instead of get.

Thank for your help, yes I will definitively brush up on js.

This message has been edited. Last edited by: paulux99,
November 14, 2013, 03:22 AM
Dave
paulux99

textarea also supports linefeeds as separator.

, ; or linefeed is supported.

G'luck


_____________________
WF: 8.0.0.9 > going 8.2.0.5