Click to See Complete Forum and Search --> : help with apostrophes


plainjoe
07-29-2003, 11:14 AM
I need to trim a variable and replace the apostophes. Can this be done?

Example: Scott O'Riley....becomes Scott O Riley

Here's the code I'm currently using....I'm having problems when I run into apostrophes like the example above. The trimAct2 is where I'm having the problem.

<SCRIPT LANGUAGE="JavaScript">
function submitForm()
{
document.theform.submit();
}
function trimAct(act)
{
var act2;
act2=act.substring(10,20);

return (act2);
}
function trimAct2(act5)
{
var act6;
act6=act5.substring(0,30);

return (act6);
}
function trimAct3(act7)
{
var act8;
act8=act7.substring(0,10);

return (act8);
}
</SCRIPT>
<HTML>
<HEAD>
<TITLE>
Show Topic Items
</TITLE>
</HEAD>
<BODY bgColor=white text=black vlink="red" link="blue" alink="navy" >
<a name="top"></a>
<FONT style="BACKGROUND-COLOR: navy" color=white size=4><CENTER>
<p>Click the links to
view a Quarterly Statement... </p>

</FONT>

<FONT style="BACKGROUND-COLOR: navy" size=4>
<p>
<font color="#FFFFFF" style="background-color: navy" size="2"><em><strong>To search for a specific
name </strong></em> </font>

</FONT>

<font color="#FFFFFF" style="background-color: navy" size="2"><em><strong>click
the EDIT menu, and then click&nbsp; FIND</strong></em></font></p>

<HR></FONT><A name=top></A>
<A href="#bottom" ><FONT size=2>Go to Bottom of the table... </FONT></A>
<TABLE BORDER=5 borderColor=gray bgcolor="#C0C0C0"><font size=3>
<tr><th> Contract # </th><th> Annuitant </th><th> Statement Date </th>
</tr>
[! BEGINHTMLTABLE Group=TopicAll Vars=TopicItemReportOut,TopicItemVersionOut,TopicItemSectionOut,TopicItemNumberPagesOut,TopicItemPag eOffsetOut]
[!COLUMN Field=TopicItemOut Link=showvaqstmt.html target="_blank" script=trimAct]
[!COLUMN Field=TopicItemSectionOut script=trimAct2]
[!COLUMN Field=TopicItemFormattedVersionOut script=trimAct3]
[!ENDHTMLTABLE ]
</TABLE>
</font>
<P align=center><A name=bottom></A><A href="#top" ><FONT size=2>Go to Top of Table</FONT><BR> </A></P>

</BODY>
</HTML>

pyro
07-29-2003, 11:22 AM
Use regexp, like this simple exampe:

<script type="text/javascript">
str = "Scott O'Riley";
str = str.replace(/'/g,"");
alert (str);
</script>

plainjoe
07-29-2003, 12:26 PM
I must be doing something wrong....here's how I coded the change.

function trimAct2(act5)
{
var act6;
act6=act5.substring(0,30);
str = "act5";
str = str.replace(/'/g,"");
alert (str);

return (act6);

pyro
07-29-2003, 12:31 PM
There is not apostrophe in what you assigned to the str variable ("act5")...

plainjoe
07-29-2003, 12:36 PM
it could be like one of the following...

Sam Wright

or

Bill Clinton

or

Tom Hanks

or

Scott O'Cconnor <----- note apostrophe

pyro
07-29-2003, 12:44 PM
Well, as you have it now, it is not variable data. I bet you ment this:

function trimAct2(act5) {
var act6;
act6=act5.substring(0,30);
str = act5; //no quotes...
str = str.replace(/'/g,"");
alert (str);
return (act6);
}

plainjoe
07-29-2003, 12:55 PM
here's the source it produced....if you do a find on connor (trimAct2)....you'll see the apostrophe still embedded.....


<SCRIPT LANGUAGE="JavaScript">
function submitForm()
{
document.theform.submit();
}
function trimAct(act)
{
var act2;
act2=act.substring(10,20);

return (act2);
}
function trimAct2(act5)
{
var act6;
act6=act5.substring(0,30);
str = act5; //no quotes...
str = str.replace(/'/g,"");
return (act6);
}
function trimAct3(act7)
{
var act8;
act8=act7.substring(0,10);

return (act8);
}
</SCRIPT>
<HTML>
<HEAD>
<TITLE>
Show Topic Items
</TITLE>
</HEAD>
<BODY bgColor=white text=black vlink="red" link="blue" alink="navy" >
<a name="top"></a>
<FONT style="BACKGROUND-COLOR: navy" color=white size=4><CENTER>
<p>Click the links to
view a Quarterly Statement... </p>

</FONT>

<FONT style="BACKGROUND-COLOR: navy" size=4>
<p>
<font color="#FFFFFF" style="background-color: navy" size="2"><em><strong>To search for a specific
name </strong></em> </font>

</FONT>

<font color="#FFFFFF" style="background-color: navy" size="2"><em><strong>click
the EDIT menu, and then click&nbsp; FIND</strong></em></font></p>

<HR></FONT><A name=top></A>
<A href="#bottom" ><FONT size=2>Go to Bottom of the table... </FONT></A>
<TABLE BORDER=5 borderColor=gray bgcolor="#C0C0C0"><font size=3>
<tr><th> Contract # </th><th> Annuitant </th><th> Statement Date </th>
</tr>
<tr>
<td><a target="_blank" href="http://ddnet2k/ddrint/bin/EBPPCGI.exe?sessionid=vauser:16624&contextid=0&template=showvaqstmt.html&table_TopicAll=0&TopicItemReportOut=VAQRTSTMT+&TopicItemVersionOut=20030630103611&TopicItemSectionOut=CAROLYN+S.+TUTTLE+++++++++++++ABSPG0000004839&TopicItemNumberPagesOut=1&TopicItemPageOffsetOut=4743548"><SCRIPT> document.write(trimAct('000Q034798JR2001462 '));</SCRIPT></a></td>
<td><SCRIPT> document.write(trimAct2('CAROLYN S. TUTTLE ABSPG0000004839'));</SCRIPT></td>
<td><SCRIPT> document.write(trimAct3('06/30/2003 10:36:11 AM'));</SCRIPT></td>
</tr>
<tr>
<td><a target="_blank" href="http://ddnet2k/ddrint/bin/EBPPCGI.exe?sessionid=vauser:16624&contextid=0&template=showvaqstmt.html&table_TopicAll=1&TopicItemReportOut=VAQRTSTMT+&TopicItemVersionOut=20030630103611&TopicItemSectionOut=JOHN+F.+AHRNS+++++++++++++++++ABSPG0000008753&TopicItemNumberPagesOut=1&TopicItemPageOffsetOut=8759800"><SCRIPT> document.write(trimAct('000Q034798JR2501969 '));</SCRIPT></a></td>
<td><SCRIPT> document.write(trimAct2('JOHN F. AHRNS ABSPG0000008753'));</SCRIPT></td>
<td><SCRIPT> document.write(trimAct3('06/30/2003 10:36:11 AM'));</SCRIPT></td>
</tr>
<tr>
<td><a target="_blank" href="http://ddnet2k/ddrint/bin/EBPPCGI.exe?sessionid=vauser:16624&contextid=0&template=showvaqstmt.html&table_TopicAll=2&TopicItemReportOut=VAQRTSTMT+&TopicItemVersionOut=20030630103611&TopicItemSectionOut=ERNIE+SELF++++++++++++++++++++ABSPG0000012409&TopicItemNumberPagesOut=1&TopicItemPageOffsetOut=12332368"><SCRIPT> document.write(trimAct('000Q034798JR2503582 '));</SCRIPT></a></td>
<td><SCRIPT> document.write(trimAct2('ERNIE SELF ABSPG0000012409'));</SCRIPT></td>
<td><SCRIPT> document.write(trimAct3('06/30/2003 10:36:11 AM'));</SCRIPT></td>
</tr>
<tr>
<td><a target="_blank" href="http://ddnet2k/ddrint/bin/EBPPCGI.exe?sessionid=vauser:16624&contextid=0&template=showvaqstmt.html&table_TopicAll=3&TopicItemReportOut=VAQRTSTMT+&TopicItemVersionOut=20030630103611&TopicItemSectionOut=SCOTT+O%27CONNOR++++++++++++++++ABSPG0000020323&TopicItemNumberPagesOut=1&TopicItemPageOffsetOut=20159537"><SCRIPT> document.write(trimAct('000Q034798JR3503672 '));</SCRIPT></a></td>
<td><SCRIPT> document.write(trimAct2('SCOTT O'CONNOR ABSPG0000020323'));</SCRIPT></td>
<td><SCRIPT> document.write(trimAct3('06/30/2003 10:36:11 AM'));</SCRIPT></td>
</tr>

</TABLE>
</font>
<P align=center><A name=bottom></A><A href="#top" ><FONT size=2>Go to Top of Table</FONT><BR> </A></P>

</BODY>
</HTML>