Solved

Onload Find/Replace (null) in Text fields

Posted on 2001-07-30
27
492 Views
Last Modified: 2013-12-03
I 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/TITLE>

  <SCRIPT LANGUAGE="JavaScript">
   <!--
   function makeonelineineverytextarea() {
   var regexCRLF = new RegExp( '/r/n', 'g' )
   var ec = document.forms[0].elements.length - 1;
   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(regexCRLF, '<br>')
   }
   }
   function makemultylineineverytextarea() {
   var regexBR = new RegExp( '<BR>', 'gi' )
   var ec = document.forms[0].elements.length - 1;
   var element = document.forms[0].elements;
   for (i= 0; i <= ec; i ++) {
    if (element[i].type == 'textarea') element[i].value = element[i].value.replace(regexBR, '\r\n')
   }
   }
   function makemultylineineverytextarea() {
   var regexBR = new RegExp( '(null)', 'gi' )
   var ec = document.forms[0].elements.length - 1;
   var element = document.forms[0].elements;
   for (i= 0; i <= ec; i ++) {
   if (element[i].type == 'textarea') element[i].value = element[i].value.replace(regexBR, '')
   if (element[i].type == 'text') element[i].value = element[i].value.replace(regexBR, '')
   if (element[i].type == 'hidden') element[i].value = element[i].value.replace(regexBR, '')
  }
  }
   // -->
</SCRIPT>
BODY BGCOLOR="#FFFFFF" LINK="#CC0000" ALINK="#00CC00" VLINK="#CC0000" onLoad="makemultylineineverytextarea()">
P>FORM ACTION="/cgi-bin/sql/update.cgi" METHOD=POST>
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">/TEXTAREA>
/TD>/TR>
/TABLE>
INPUT TYPE=submit VALUE="Submit" onClick="makeonelineineverytextarea()"> P>
/FONT>/CENTER>
/FORM>
/TD>
/TR>
/TABLE>
 /FONT>
/BODY>
/HTML>
0
Comment
Question by:trailerman
27 Comments
 
LVL 1

Expert Comment

by:coreyti
ID: 6336779
Seems to me that you need to add a call to your other function to your onload statement so that you have:

----------
onLoad="makeonelineineverytextarea(); makemultylineineverytextarea()"
----------

and you should change both for loops from:

----------
for (i= 0; i = ec; i ++)
----------

to

----------
// less than
for (i= 0; i < ec; i ++)
----------


-corey
0
 

Author Comment

by:trailerman
ID: 6337857
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?
0
 

Expert Comment

by:owlsey
ID: 6337874
name them seperately- just call both function with the onload
0
 
LVL 1

Expert Comment

by:pjtt
ID: 6337949
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.getElementsByTagName) == "function" && document.getElementsByTagName("*")) {
        document.all = document.getElementsByTagName("*")
     }
}
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/peter
0
 
LVL 2

Expert Comment

by:coreyit
ID: 6339706
as owlsey stated, what I mean is for you to "call" (run) both functions ( makeonelineineverytextarea() and makemultylineineverytextarea() ) from the same onload event in your body tag.

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
0
 

Author Comment

by:trailerman
ID: 6340816
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...
0
 
LVL 1

Expert Comment

by:pjtt
ID: 6341409
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, "<br>", f) // find occurances of either one alone
     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.replace(Find, sReplace);
               }
          } else {
               f.elements[i].value = f.elements[i].value.replace(Find, sReplace);
          }
     }
}

// -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#CC0000" ALINK="#00CC00" VLINK="#CC0000" onLoad="initialize()">



Hope this helps!!

Peter Tracey
Developer
http://www.25online.com/peter
0
 

Author Comment

by:trailerman
ID: 6341801
pji and others:

Isimplified(modified) the question, as I need to work with existing script. Please see, I don't know java script so I simply need someone to tell me how to write code properly per revised question.

thanks
0
 
LVL 1

Expert Comment

by:pjtt
ID: 6341835
The code I gave you does exactly what you want.

Peter Tracey
Developer
http://www.25online.com/peter
0
 
LVL 1

Expert Comment

by:pjtt
ID: 6341843
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.replace(Find, sReplace);
              }
         } else {
              f.elements[i].value = f.elements[i].value.replace(Find, sReplace);
         }
    }
}
0
 
LVL 1

Expert Comment

by:pjtt
ID: 6341846
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.replace(Find, sReplace);
             }
        } else {
             f.elements[i].value = f.elements[i].value.replace(Find, sReplace);
        }
   }
}
0
 

Author Comment

by:trailerman
ID: 6341884
I can't yours to work..(not saying it doesn't on your end), I'm just looking for answer to the "(null)" element, can you help?  thanks much.
0
 
LVL 1

Expert Comment

by:pjtt
ID: 6341923
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/peter


<HTML><HEAD><TITLE>task.htm</TITLE>

<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, "<br>", f) // find occurances of either one alone
     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.replace(Find, sReplace);
               }
          } else {
               f.elements[i].value = f.elements[i].value.replace(Find, sReplace);
          }
     }
}

// -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#CC0000" ALINK="#00CC00" VLINK="#CC0000" onLoad="initialize()">
<P><FORM ACTION="/cgi-bin/sql/update.cgi" METHOD=POST>
<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">nullnullnull</TEXTAREA>
</TD></TR>
</TABLE>
<INPUT TYPE=submit VALUE="Submit" onClick="makeonelineineverytextarea()"> <P>
</FONT></CENTER>
</FORM>
</TD>
</TR>
</TABLE>
</FONT>
</BODY>
</HTML>
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:trailerman
ID: 6341950
thanks anyway... I figured it out with the use of' [(null)]'

Your java skills are good, I'm sure, but just needed a quick answer to my modification
 question. thanks for the effort anyway.
0
 
LVL 1

Expert Comment

by:pjtt
ID: 6341960
[(null)] is a character set... you're going to get very unexpected results even though it seems to work in your test.
0
 
LVL 1

Expert Comment

by:pjtt
ID: 6341963
...It'll replace any occurance of "n", "u", or "l"
0
 

Author Comment

by:trailerman
ID: 6342115
yes, you're right. the [] takes out the "n" from the Name=   value.

So what can I do to constrain it from just pulling out the '(null)'  and
not messing with anything else.  is there another way to express
the '(' and ')" on both sides of the null.

respectly resumbitting question to you pjit
0
 
LVL 1

Expert Comment

by:pjtt
ID: 6342123
...It'll replace any occurance of "n", "u", or "l"
0
 
LVL 1

Expert Comment

by:pjtt
ID: 6342149
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/peter

<TABLE WIDTH=87% BORDER=1 CELLPADDING=5 CELLSPACING=0>
<TR VALIGN=TOP BGCOLOR="#DDDDDD">
<TD><FONT SIZE=2><b>Character</b></FONT></TD>
<TD><FONT SIZE=2><b>Description</b></FONT></TD></TR>
<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</i><b>)</b> </font></td>
<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>y</i></font></td>
<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>}</b></font></td>
<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>,}</b> </font></td>
<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>,</b><i>m</i><b>}</b> </font></td>
<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><b>]</b> </font></td>
<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><b>]</b> </font></td>
<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><b>]</b> </font></td>
<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><b>]</b> </font></td>
<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 "[&nbsp;\f\n\r\t\v]".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\S</b> </font></td>
<td><font size=2>Matches any nonwhite space character. Equivalent to "[^&nbsp;\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></font></td>
<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></font></td>
<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>
0
 

Author Comment

by:trailerman
ID: 6342150
so are you saying that there is no answer to my  specific question, and your answer is only possible solution?
0
 
LVL 1

Expert Comment

by:pjtt
ID: 6342155
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/peter

<TABLE WIDTH=87% BORDER=1 CELLPADDING=5 CELLSPACING=0>
<TR VALIGN=TOP BGCOLOR="#DDDDDD">
<TD><FONT SIZE=2><b>Character</b></FONT></TD>
<TD><FONT SIZE=2><b>Description</b></FONT></TD></TR>
<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</i><b>)</b> </font></td>
<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>y</i></font></td>
<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>}</b></font></td>
<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>,}</b> </font></td>
<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>,</b><i>m</i><b>}</b> </font></td>
<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><b>]</b> </font></td>
<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><b>]</b> </font></td>
<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><b>]</b> </font></td>
<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><b>]</b> </font></td>
<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 "[&nbsp;\f\n\r\t\v]".</font></td>
</tr>
<tr valign=top>
<td><font size=2><b>\S</b> </font></td>
<td><font size=2>Matches any nonwhite space character. Equivalent to "[^&nbsp;\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></font></td>
<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></font></td>
<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>
0
 
LVL 1

Expert Comment

by:pjtt
ID: 6342162
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/peter
0
 

Author Comment

by:trailerman
ID: 6342174
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 makemultylineineverytextarea() {
     var regexBR = new RegExp( '\(null\)', 'gi' )
     var ec = document.forms[0].elements.length - 1;
     var element = document.forms[0].elements;
     for (i= 0; i <= ec; i ++) {
     if (element[i].type == 'textarea') element[i].value = element[i].value.replace(regexBR, '')
     if (element[i].type == 'text') element[i].value = element[i].value.replace(regexBR, '')
     if (element[i].type == 'hidden') element[i].value = element[i].value.replace(regexBR, '')
0
 
LVL 1

Expert Comment

by:pjtt
ID: 6342219
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/peter
0
 
LVL 1

Expert Comment

by:pjtt
ID: 6342304
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/peter
0
 
LVL 1

Accepted Solution

by:
pjtt earned 300 total points
ID: 6342315
<HTML><HEAD><TITLE>task.htm</TITLE>

<SCRIPT LANGUAGE="JavaScript">
<!--
function makeonelineineverytextarea() {
       var regexCRLF = new RegExp( '/r/n', 'g' )
       var ec = document.forms[0].elements.length - 1;
       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(regexCRLF, '<br>')
       }
       makemultylineineverytextarea()
}
function makemultylineineverytextarea() {
       var regexBR = new RegExp( '<BR>', 'gi' )
       var ec = document.forms[0].elements.length - 1;
       var element = document.forms[0].elements;
       for (i= 0; i <= ec; i ++) {
             if (element[i].type == 'textarea') element[i].value = element[i].value.replace(regexBR, '\r\n')
       }
       makenonullsineverytextarea()
}
function makenonullsineverytextarea() {
     var regexBR = new RegExp( '[\(]?null[\)]?', 'gi' )
     var ec = document.forms[0].elements.length - 1;
     var element = document.forms[0].elements;
     for (i= 0; i <= ec; i ++) {
          if (element[i].type == 'textarea') element[i].value = element[i].value.replace(regexBR, '')
          if (element[i].type == 'text') element[i].value = element[i].value.replace(regexBR, '')
          if (element[i].type == 'hidden') element[i].value = element[i].value.replace(regexBR, '')
     }
}
// -->
</SCRIPT>
<BODY BGCOLOR="#FFFFFF" LINK="#CC0000" ALINK="#00CC00" VLINK="#CC0000" onLoad="makemultylineineverytextarea()">
<P><FORM ACTION="/cgi-bin/sql/update.cgi" METHOD=POST>
<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="makeonelineineverytextarea()"> <P>
</FONT></CENTER>
</FORM>
</TD>
</TR>
</TABLE>
</FONT>
</BODY>
</HTML>
0
 

Author Comment

by:trailerman
ID: 6342504
impressive range of java knowledge
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now