codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  HELP WITH STRINGS :(  mike31 at 22:05 on Tuesday, April 19, 2005
 

We have to create a program that first, accepts a string from the user (up to 80 words, then, it acts the user the choose which word they want to replace in that string, and finally, they have to write in the string to REPLACE IT WITH.

I need the return method.

return (str,str,str)

HELP PLESE :(

  Re: HELP WITH STRINGS :(  kanad at 13:25 on Thursday, April 21, 2005
 

Hello mike31
Try this code

<HTML>
<HEAD>
<TITLE>String Replace Code</TITLE>
<script type="text/javascript">
var retStr=new Array(3);

function replace(string,text,by)
{
var myString=string;
while(myString.indexOf(text)!=-1)
{
myString=myString.replace(text,by);
}
retStr[0]=myString;
retStr[1]=text;
retStr[2]=by;
return retStr;
}
var strMsg='You want to Replace XX with AB in string ABCDAB';
strMsg=strMsg+'\nYou can use replace("ABCDAB","AB","XX")';
strMsg=strMsg+"You get Value "+replace("ABCDAB","AB","XX");
strMsg=strMsg+"\nYour Replaced String "+replace("ABCDAB","AB","XX")[0];
document.write(strMsg);


</script>

</HEAD>
<BODY>



</BODY>
</HTML>




© Copyright codetoad.com 2001-2005