Should the both onload fuctions be named the same?... what do you mean should add another call function. How will it know to pullout "(null)" value?
Main Topics
Browse All TopicsI need to fix the last function of my existing script. It currently performs a find/replace function
of <BR> and carriage returns. They work fine, and my only help needed is as follows
and again related to last js function:
It is looking for the '(null)' value and it does find it, but it replaces it with "()"
what do I have to change (only in last js function), so it removes/deletes
the entire value ( paranthesis and the null)?
thanks.
Thank you.
<HTML>HEAD>TITLE>task.htm/
<SCRIPT LANGUAGE="JavaScript">
<!--
function makeonelineineverytextarea
var regexCRLF = new RegExp( '/r/n', 'g' )
var ec = document.forms[0].elements
var element = document.forms[0].elements
for (i= 0; i <= ec; i ++) {
//alert('elemnt('+i+'): '+element[i].type)
if (element[i].type == 'textarea') element[i].value = element[i].value.replace(r
}
}
function makemultylineineverytextar
var regexBR = new RegExp( '<BR>', 'gi' )
var ec = document.forms[0].elements
var element = document.forms[0].elements
for (i= 0; i <= ec; i ++) {
if (element[i].type == 'textarea') element[i].value = element[i].value.replace(r
}
}
function makemultylineineverytextar
var regexBR = new RegExp( '(null)', 'gi' )
var ec = document.forms[0].elements
var element = document.forms[0].elements
for (i= 0; i <= ec; i ++) {
if (element[i].type == 'textarea') element[i].value = element[i].value.replace(r
if (element[i].type == 'text') element[i].value = element[i].value.replace(r
if (element[i].type == 'hidden') element[i].value = element[i].value.replace(r
}
}
// -->
</SCRIPT>
BODY BGCOLOR="#FFFFFF" LINK="#CC0000" ALINK="#00CC00" VLINK="#CC0000" onLoad="makemultylineineve
P>FORM ACTION="/cgi-bin/sql/updat
CENTER>INPUT TYPE=hidden NAME=template VALUE="staff/back.htm">
INPUT TYPE=hidden NAME="ID_field" VALUE="tasks.tasks_ID">
INPUT TYPE=hidden NAME="ID_value" VALUE="{{tasks.tasks_ID}}"
INPUT TYPE=hidden NAME="tasks.date_updated" VALUE="system_date">
INPUT TYPE=hidden NAME="tasks.name_updated" VALUE="{{tasks.staff_name}
H3>CENTER>Update Tasks /CENTER>/H3>
FONT SIZE="-1" FACE="Arial, Helvetica">
table cellspacing=2 cellpadding=0 width="80%">
tr> td height="25"> FONT SIZE="-1" FACE="Verdana">Title: /FONT>
/TD>td height="25">
FONT SIZE="-1" FACE="Verdana">P>input type=text name="tasks.tasks_title" size=25 maxlength=100>/FONT>
/TD>
/TR>
tr>td height="18">FONT SIZE="-1" FACE="Verdana">Category: /FONT>
/TD>
td height="18">
FONT SIZE="-1" FACE="Verdana">input type=text name="tasks.category" size=25 maxlength=100>
/FONT>
/TD>
/TR>
tr>
td>
FONT SIZE="-1" FACE="Verdana"> Notes
/td>td>P>textarea rows=3 cols=35 wrap="soft" name="tasks.note">/TEXTARE
/TD>/TR>
/TABLE>
INPUT TYPE=submit VALUE="Submit" onClick="makeonelineinever
/FONT>/CENTER>
/FORM>
/TD>
/TR>
/TABLE>
/FONT>
/BODY>
/HTML>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Are you just trying to search the form elements or the HTML too? Searching the form elements would be easy, just add another reg exp that looks for "null" - searching the HTML would be tricky though. You should check for null values before you send stuff to the client, not after.
If you still want to, well here's an IE/NS6 solution. Make sure you give every element an ID or a name. Load the entire HTML, searching for occurances of <[.\n]*null - that's the "<" character, and number of characters, and then "null". The reason you search for "<" is because you want to access the last tag before the word null. Then back up in the string to find the ID of that tag, and then you can just replace the text there. Otherwise you can do
for (var i=0; document.all[i]; i++) //look for "null" and replace it here
use this code to get document.all in NS6:
function getAllCollection() {
if (typeof(document.getElemen
document.all = document.getElementsByTagN
}
}
if (!document.all) getAllCollection();
It's probably possible to do it in browsers other than IE4+/NS6, but far more complicated.
Peter Tracey
Developer
http://www.25online.com/pe
as owlsey stated, what I mean is for you to "call" (run) both functions ( makeonelineineverytextarea
once that is done, be sure to correct the "for" loops so they run as long as the counter is less-than the number of form elements (will cover every element and then stop).
-corey
pjtt , I wanted to search all textfields and textareas (hidden or not) to delete all "null" values, and do this onload in cunjunction with other javascript function in above script. here are the area and fields types for example:
input type="text" value=null
input type="textarea" value=null
input type="hidden" value=null
so best to write any function, that searches where value = or includes "null" value, would you agree?
I don't understand javascript formatting so please send me complete modified javascript or better the entire html.
thank you...
I wrote a function formFindReplace() that takes a string to search for, a string to replace it with, and a form object. Onload initialize() is called, which does the replaces for new lines and nulls. I noticed you only have text elements and no selects, checkboxes, etc. on your form, so I only coded for those (though I did allow for the possibility of multiple textboxes with the same name). If you add other elements you'll have to check either the name or the type of the element before you try to run the replace method.
<SCRIPT LANGUAGE="JavaScript">
!--
function initialize() {
var f = document.forms[0];
formFindReplace(/\r\n/g, "<br>", f) // finds occurances of carraige-return line-feed
formFindReplace(/[\r\n]/g,
formFindReplace("null", "", f) // find occurances of either one alone
}
function formFindReplace(Find, sReplace, f) {
for (var i=0; i<f.elements.length; i++) {
if (f.elements[i].length) {
for (var j=0; j<f.elements[i].length; j++) {
f.elements[i][j].value = f.elements[i][j].value.rep
}
} else {
f.elements[i].value = f.elements[i].value.replac
}
}
}
// -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#CC0000" ALINK="#00CC00" VLINK="#CC0000" onLoad="initialize()">
Hope this helps!!
Peter Tracey
Developer
http://www.25online.com/pe
The code I gave you does exactly what you want.
Peter Tracey
Developer
http://www.25online.com/pe
here's a modified version that checkes the type of the element before doing the replace:
function formFindReplace(Find, sReplace, f) {
if (f.elements[i].type != "text" && f.elements[i].type != "textarea" && f.elements[i].type != "hidden") continue;
for (var i=0; i<f.elements.length; i++) {
if (f.elements[i].length) {
for (var j=0; j<f.elements[i].length; j++) {
f.elements[i][j].value = f.elements[i][j].value.rep
}
} else {
f.elements[i].value = f.elements[i].value.replac
}
}
}
Oops:
function formFindReplace(Find, sReplace, f) {
for (var i=0; i<f.elements.length; i++) {
if (f.elements[i].type != "text" && f.elements[i].type != "textarea" && f.elements[i].type != "hidden")
continue;
if (f.elements[i].length) {
for (var j=0; j<f.elements[i].length; j++) {
f.elements[i][j].value = f.elements[i][j].value.rep
}
} else {
f.elements[i].value = f.elements[i].value.replac
}
}
}
Here's the complete HTML for my solution.
If you still can't get it to work... to replace null just copy the reg exp I'm using in there: ((new RegExp("null", "g"))
The problem with your updated page is that you have two functions with the same name, so it's just chosing one to run (either the first or the last, I'm not sure). Try my code first though because it's much cleaner.
Peter Tracey
Developer
http://www.25online.com/pe
<HTML><HEAD><TITLE>task.ht
<SCRIPT LANGUAGE="JavaScript">
!--
function initialize() {
var f = document.forms[0];
formFindReplace(/\r\n/g, "<br>", f) // finds occurances of carraige-return line-feed
formFindReplace(/[\r\n]/g,
formFindReplace((new RegExp("null", "g")), "", f) // find occurances of either one alone
}
function formFindReplace(Find, sReplace, f) {
for (var i=0; i<f.elements.length; i++) {
if (f.elements[i].type != "text" && f.elements[i].type != "textarea" && f.elements[i].type != "hidden") continue;
if (f.elements[i].length) {
for (var j=0; j<f.elements[i].length; j++) {
f.elements[i][j].value = f.elements[i][j].value.rep
}
} else {
f.elements[i].value = f.elements[i].value.replac
}
}
}
// -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#CC0000" ALINK="#00CC00" VLINK="#CC0000" onLoad="initialize()">
<P><FORM ACTION="/cgi-bin/sql/updat
<CENTER><INPUT TYPE=hidden NAME=template VALUE="staff/back.htm">
<INPUT TYPE=hidden NAME="ID_field" VALUE="tasks.tasks_ID">
<INPUT TYPE=hidden NAME="ID_value" VALUE="{{tasks.tasks_ID}}"
<INPUT TYPE=hidden NAME="tasks.date_updated" VALUE="system_date">
<INPUT TYPE=hidden NAME="tasks.name_updated" VALUE="{{tasks.staff_name}
<H3><CENTER>Update Tasks </CENTER></H3>
<FONT SIZE="-1" FACE="Arial, Helvetica">
<table cellspacing=2 cellpadding=0 width="80%">
<tr> <td height="25"> <FONT SIZE="-1" FACE="Verdana">Title: </FONT>
</TD><td height="25">
<FONT SIZE="-1" FACE="Verdana"><P><input type=text name="tasks.tasks_title" size=25 maxlength=100></FONT>
</TD>
</TR>
<tr><td height="18"><FONT SIZE="-1" FACE="Verdana">Category: </FONT>
</TD>
<td height="18">
<FONT SIZE="-1" FACE="Verdana"><input type=text name="tasks.category" size=25 maxlength=100>
</FONT>
</TD>
</TR>
<tr>
<td>
<FONT SIZE="-1" FACE="Verdana"> Notes
</td><td><P><textarea rows=3 cols=35 wrap="soft" name="tasks.note">nullnull
</TD></TR>
</TABLE>
<INPUT TYPE=submit VALUE="Submit" onClick="makeonelineinever
</FONT></CENTER>
</FORM>
</TD>
</TR>
</TABLE>
</FONT>
</BODY>
</HTML>
The "(" and ")" characters have meaning in regular expressions, so you have to escape them with "\".
new RegExp("\(null\)", "g")
will replace any occurance of "(null)".
or if you also want to replace it if it doesn't have the () then:
new RegExp("\(?null\)?", "g")
will replace any occurance of "(null)" or "null"
I wrote an XML parser in JavaScript based on regular expressions (jsxml.homestead.com) so I'm good with them.
Here's the complete guide (from M$) to JavaScript regular expression syntax.
Peter Tracey
Developer
http://www.25online.com/pe
<TABLE WIDTH=87% BORDER=1 CELLPADDING=5 CELLSPACING=0>
<TR VALIGN=TOP BGCOLOR="#DDDDDD">
<TD><FONT SIZE=2><b>Character</b></F
<TD><FONT SIZE=2><b>Description</b><
<tr valign=top>
<td><font size=2><b>\</b> </font></td>
<td><font size=2>Marks the next character as either a special character or a literal. For example, "n" matches the character "n". "\n" matches a newline character. The sequence "\\" matches "\" and "\(" matches "(".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>^</b> </font></td>
<td><font size=2>Matches the beginning of input.</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>$</b> </font></td>
<td><font size=2>Matches the end of input.</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>*</b> </font></td>
<td><font size=2>Matches the preceding character zero or more times. For example, "zo*" matches either "z" or "zoo".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>+</b> </font></td>
<td><font size=2>Matches the preceding character one or more times. For example, "zo+" matches "zoo" but not "z". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>?</b> </font></td>
<td><font size=2>Matches the preceding character zero or one time. For example, "a?ve?" matches the "ve" in "never". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>.</b></font></td
<td><font size=2>Matches any single character except a newline character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>(</b><i>pattern<
<td><font size=2>Matches <i>pattern</i> and remembers the match. The matched substring can be retrieved from the resulting <b>Matches</b> collection, using Item <b>[0]...[n]</b>. To match parentheses characters ( ), use "\(" or "\)".</font></td>
</tr>
<tr valign=top>
<td><font size=2><i>x</i><b>|</b><i>
<td><font size=2>Matches either <i>x</i> or <i>y</i>. For example, "z|food" matches "z" or "food". "(z|f)ood" matches "zoo" or "food". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>{</b><i>n</i><b>
<td><font size=2><i>n</i> is a nonnegative integer. Matches exactly <i>n</i> times. For example, "o{2}" does not match the "o" in "Bob," but matches the first two o's in "foooood".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>{</b><i>n</i><b>
<td><font size=2><i>n</i> is a nonnegative integer. Matches at least <i>n</i> times. For example, "o{2,}" does not match the "o" in "Bob" and matches all the o's in "foooood". "o{1,}" is equivalent to "o+". "o{0,}" is equivalent to "o*".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>{</b><i>n</i><b>
<td><font size=2><i>m</i> and <i>n</i> are nonnegative integers. Matches at least <i>n</i> and at most <i>m</i> times. For example, "o{1,3}" matches the first three o's in "fooooood". "o{0,1}" is equivalent to "o?".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>[</b><i>xyz</i><
<td><font size=2>A character set. Matches any one of the enclosed characters. For example, "[abc]" matches the "a" in "plain". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>[^</b><i>xyz</i>
<td><font size=2>A negative character set. Matches any character not enclosed. For example, "[^abc]" matches the "p" in "plain". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>[</b><i>a-z</i><
<td><font size=2>A range of characters. Matches any character in the specified range. For example, "[a-z]" matches any lowercase alphabetic character in the range "a" through "z". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>[^</b><i>m-z</i>
<td><font size=2>A negative range characters. Matches any character not in the specified range. For example, "[m-z]" matches any character not in the range "m" through "z". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\b</b> </font></td>
<td><font size=2>Matches a word boundary, that is, the position between a word and a space. For example, "er\b" matches the "er" in "never" but not the "er" in "verb". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\B</b> </font></td>
<td><font size=2>Matches a nonword boundary. "ea*r\B" matches the "ear" in "never early". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\d</b> </font></td>
<td><font size=2>Matches a digit character. Equivalent to [0-9]. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\D</b> </font></td>
<td><font size=2>Matches a nondigit character. Equivalent to [^0-9]. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\f</b> </font></td>
<td><font size=2>Matches a form-feed character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\n</b> </font></td>
<td><font size=2>Matches a newline character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\r</b> </font></td>
<td><font size=2>Matches a carriage return character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\s</b> </font></td>
<td><font size=2>Matches any white space including space, tab, form-feed, etc. Equivalent to "[ \f\n\r\t\v]".</fon
</tr>
<tr valign=top>
<td><font size=2><b>\S</b> </font></td>
<td><font size=2>Matches any nonwhite space character. Equivalent to "[^ \f\n\r\t\v]". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\t</b> </font></td>
<td><font size=2>Matches a tab character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\v</b> </font></td>
<td><font size=2>Matches a vertical tab character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\w</b> </font></td>
<td><font size=2>Matches any word character including underscore. Equivalent to "[A-Za-z0-9_]". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\W</b> </font></td>
<td><font size=2>Matches any nonword character. Equivalent to "[^A-Za-z0-9_]". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\</b><i>num</i> </font></td>
<td><font size=2>Matches <i>num</i>, where <i>num</i> is a positive integer. A reference back to remembered matches. For example, "(.)\1" matches two consecutive identical characters. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\</b><i>n</i></f
<td><font size=2>Matches <i>n</i>, where <i>n</i> is an octal escape value. Octal escape values must be 1, 2, or 3 digits long. For example, "\11" and "\011" both match a tab character. "\0011" is the equivalent of "\001" & "1". Octal escape values must not exceed 256. If they do, only the first two digits comprise the expression. Allows ASCII codes to be used in regular expressions.</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\x</b><i>n</i></
<td><font size=2>Matches <i>n</i>, where <i>n</i> is a hexadecimal escape value. Hexadecimal escape values must be exactly two digits long. For example, "\x41" matches "A". "\x041" is equivalent to "\x04" & "1". Allows ASCII codes to be used in regular expressions.</font></td>
</tr>
</TABLE>
The "(" and ")" characters have meaning in regular expressions, so you have to escape them with "\".
new RegExp("\(null\)", "g")
will replace any occurance of "(null)".
or if you also want to replace it if it doesn't have the () then:
new RegExp("\(?null\)?", "g")
will replace any occurance of "(null)" or "null"
I wrote an XML parser in JavaScript based on regular expressions (jsxml.homestead.com) so I'm good with them.
Here's the complete guide (from M$) to JavaScript regular expression syntax.
Peter Tracey
Developer
http://www.25online.com/pe
<TABLE WIDTH=87% BORDER=1 CELLPADDING=5 CELLSPACING=0>
<TR VALIGN=TOP BGCOLOR="#DDDDDD">
<TD><FONT SIZE=2><b>Character</b></F
<TD><FONT SIZE=2><b>Description</b><
<tr valign=top>
<td><font size=2><b>\</b> </font></td>
<td><font size=2>Marks the next character as either a special character or a literal. For example, "n" matches the character "n". "\n" matches a newline character. The sequence "\\" matches "\" and "\(" matches "(".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>^</b> </font></td>
<td><font size=2>Matches the beginning of input.</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>$</b> </font></td>
<td><font size=2>Matches the end of input.</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>*</b> </font></td>
<td><font size=2>Matches the preceding character zero or more times. For example, "zo*" matches either "z" or "zoo".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>+</b> </font></td>
<td><font size=2>Matches the preceding character one or more times. For example, "zo+" matches "zoo" but not "z". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>?</b> </font></td>
<td><font size=2>Matches the preceding character zero or one time. For example, "a?ve?" matches the "ve" in "never". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>.</b></font></td
<td><font size=2>Matches any single character except a newline character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>(</b><i>pattern<
<td><font size=2>Matches <i>pattern</i> and remembers the match. The matched substring can be retrieved from the resulting <b>Matches</b> collection, using Item <b>[0]...[n]</b>. To match parentheses characters ( ), use "\(" or "\)".</font></td>
</tr>
<tr valign=top>
<td><font size=2><i>x</i><b>|</b><i>
<td><font size=2>Matches either <i>x</i> or <i>y</i>. For example, "z|food" matches "z" or "food". "(z|f)ood" matches "zoo" or "food". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>{</b><i>n</i><b>
<td><font size=2><i>n</i> is a nonnegative integer. Matches exactly <i>n</i> times. For example, "o{2}" does not match the "o" in "Bob," but matches the first two o's in "foooood".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>{</b><i>n</i><b>
<td><font size=2><i>n</i> is a nonnegative integer. Matches at least <i>n</i> times. For example, "o{2,}" does not match the "o" in "Bob" and matches all the o's in "foooood". "o{1,}" is equivalent to "o+". "o{0,}" is equivalent to "o*".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>{</b><i>n</i><b>
<td><font size=2><i>m</i> and <i>n</i> are nonnegative integers. Matches at least <i>n</i> and at most <i>m</i> times. For example, "o{1,3}" matches the first three o's in "fooooood". "o{0,1}" is equivalent to "o?".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>[</b><i>xyz</i><
<td><font size=2>A character set. Matches any one of the enclosed characters. For example, "[abc]" matches the "a" in "plain". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>[^</b><i>xyz</i>
<td><font size=2>A negative character set. Matches any character not enclosed. For example, "[^abc]" matches the "p" in "plain". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>[</b><i>a-z</i><
<td><font size=2>A range of characters. Matches any character in the specified range. For example, "[a-z]" matches any lowercase alphabetic character in the range "a" through "z". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>[^</b><i>m-z</i>
<td><font size=2>A negative range characters. Matches any character not in the specified range. For example, "[m-z]" matches any character not in the range "m" through "z". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\b</b> </font></td>
<td><font size=2>Matches a word boundary, that is, the position between a word and a space. For example, "er\b" matches the "er" in "never" but not the "er" in "verb". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\B</b> </font></td>
<td><font size=2>Matches a nonword boundary. "ea*r\B" matches the "ear" in "never early". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\d</b> </font></td>
<td><font size=2>Matches a digit character. Equivalent to [0-9]. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\D</b> </font></td>
<td><font size=2>Matches a nondigit character. Equivalent to [^0-9]. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\f</b> </font></td>
<td><font size=2>Matches a form-feed character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\n</b> </font></td>
<td><font size=2>Matches a newline character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\r</b> </font></td>
<td><font size=2>Matches a carriage return character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\s</b> </font></td>
<td><font size=2>Matches any white space including space, tab, form-feed, etc. Equivalent to "[ \f\n\r\t\v]".</fon
</tr>
<tr valign=top>
<td><font size=2><b>\S</b> </font></td>
<td><font size=2>Matches any nonwhite space character. Equivalent to "[^ \f\n\r\t\v]". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\t</b> </font></td>
<td><font size=2>Matches a tab character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\v</b> </font></td>
<td><font size=2>Matches a vertical tab character. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\w</b> </font></td>
<td><font size=2>Matches any word character including underscore. Equivalent to "[A-Za-z0-9_]". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\W</b> </font></td>
<td><font size=2>Matches any nonword character. Equivalent to "[^A-Za-z0-9_]". </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\</b><i>num</i> </font></td>
<td><font size=2>Matches <i>num</i>, where <i>num</i> is a positive integer. A reference back to remembered matches. For example, "(.)\1" matches two consecutive identical characters. </font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\</b><i>n</i></f
<td><font size=2>Matches <i>n</i>, where <i>n</i> is an octal escape value. Octal escape values must be 1, 2, or 3 digits long. For example, "\11" and "\011" both match a tab character. "\0011" is the equivalent of "\001" & "1". Octal escape values must not exceed 256. If they do, only the first two digits comprise the expression. Allows ASCII codes to be used in regular expressions.</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\x</b><i>n</i></
<td><font size=2>Matches <i>n</i>, where <i>n</i> is a hexadecimal escape value. Hexadecimal escape values must be exactly two digits long. For example, "\x41" matches "A". "\x041" is equivalent to "\x04" & "1". Allows ASCII codes to be used in regular expressions.</font></td>
</tr>
</TABLE>
No, here's the answer:
new RegExp("\(null\)", "gi")
The code you have will work ok if you rename the third function so that it is unique, call all three functions in the onload event (or call the second from the first and the third from the second..), and fix the regular expression with those escape ("\") characters.
The code I gave you, however, is a cleaner solution, you just have to replace "null" with "\(null\)"
Peter Tracey
Developer
http://www.25online.com/pe
I use apostrafy not quotes... and can you send me the complete code changes that
you are talking about here is what I have, but still doesn't replace paranthesis, just null portion
of text:
}
}
function makemultylineineverytextar
var regexBR = new RegExp( '\(null\)', 'gi' )
var ec = document.forms[0].elements
var element = document.forms[0].elements
for (i= 0; i <= ec; i ++) {
if (element[i].type == 'textarea') element[i].value = element[i].value.replace(r
if (element[i].type == 'text') element[i].value = element[i].value.replace(r
if (element[i].type == 'hidden') element[i].value = element[i].value.replace(r
No, here's the answer:
new RegExp("\(null\)", "gi")
The code you have will work ok if you rename the third function so that it is unique, call all three functions in the onload event (or call the second from the first and the third from the second..), and fix the regular expression with those escape ("\") characters.
The code I gave you, however, is a cleaner solution, you just have to replace "null" with "\(null\)"
Peter Tracey
Developer
http://www.25online.com/pe
No, here's the answer:
new RegExp("\(null\)", "gi")
The code you have will work ok if you rename the third function so that it is unique, call all three functions in the onload event (or call the second from the first and the third from the second..), and fix the regular expression with those escape ("\") characters.
The code I gave you, however, is a cleaner solution, you just have to replace "null" with "\(null\)"
Peter Tracey
Developer
http://www.25online.com/pe
<HTML><HEAD><TITLE>task.ht
<SCRIPT LANGUAGE="JavaScript">
<!--
function makeonelineineverytextarea
var regexCRLF = new RegExp( '/r/n', 'g' )
var ec = document.forms[0].elements
var element = document.forms[0].elements
for (i= 0; i <= ec; i ++) {
//alert('elemnt('+i+'): '+element[i].type)
if (element[i].type == 'textarea') element[i].value = element[i].value.replace(r
}
makemultylineineverytextar
}
function makemultylineineverytextar
var regexBR = new RegExp( '<BR>', 'gi' )
var ec = document.forms[0].elements
var element = document.forms[0].elements
for (i= 0; i <= ec; i ++) {
if (element[i].type == 'textarea') element[i].value = element[i].value.replace(r
}
makenonullsineverytextarea
}
function makenonullsineverytextarea
var regexBR = new RegExp( '[\(]?null[\)]?', 'gi' )
var ec = document.forms[0].elements
var element = document.forms[0].elements
for (i= 0; i <= ec; i ++) {
if (element[i].type == 'textarea') element[i].value = element[i].value.replace(r
if (element[i].type == 'text') element[i].value = element[i].value.replace(r
if (element[i].type == 'hidden') element[i].value = element[i].value.replace(r
}
}
// -->
</SCRIPT>
<BODY BGCOLOR="#FFFFFF" LINK="#CC0000" ALINK="#00CC00" VLINK="#CC0000" onLoad="makemultylineineve
<P><FORM ACTION="/cgi-bin/sql/updat
<CENTER><INPUT TYPE=hidden NAME=template VALUE="staff/back.htm">
<INPUT TYPE=hidden NAME="ID_field" VALUE="tasks.tasks_ID">
<INPUT TYPE=hidden NAME="ID_value" VALUE="{{tasks.tasks_ID}}"
<INPUT TYPE=hidden NAME="tasks.date_updated" VALUE="system_date">
<INPUT TYPE=hidden NAME="tasks.name_updated" VALUE="{{tasks.staff_name}
<H3>CENTER>Update Tasks </CENTER></H3>
<FONT SIZE="-1" FACE="Arial, Helvetica">
<table cellspacing=2 cellpadding=0 width="80%">
<tr> <td height="25"> <FONT SIZE="-1" FACE="Verdana">Title: </FONT>
</TD><td height="25">
<FONT SIZE="-1" FACE="Verdana"><P><input type=text name="tasks.tasks_title" size=25 maxlength=100></FONT>
</TD>
</TR>
<tr><td height="18"><FONT SIZE="-1" FACE="Verdana">Category: </FONT>
</TD>
<td height="18">
<FONT SIZE="-1" FACE="Verdana"><input type=text name="tasks.category" size=25 maxlength=100>
</FONT>
</TD>
</TR>
<tr>
<td>
<FONT SIZE="-1" FACE="Verdana"> Notes
</td><td><P><textarea rows=3 cols=35 wrap="soft" name="tasks.note">(null) null asdf (null</TEXTAREA>
</TD></TR>
</TABLE>
<INPUT TYPE=submit VALUE="Submit" onClick="makeonelineinever
</FONT></CENTER>
</FORM>
</TD>
</TR>
</TABLE>
</FONT>
</BODY>
</HTML>
Business Accounts
Answer for Membership
by: coreytiPosted on 2001-07-30 at 23:29:09ID: 6336779
Seems to me that you need to add a call to your other function to your onload statement so that you have:
textarea() ; makemultylineineverytextar ea()"
----------
onLoad="makeonelineinevery
----------
and you should change both for loops from:
----------
for (i= 0; i = ec; i ++)
----------
to
----------
// less than
for (i= 0; i < ec; i ++)
----------
-corey