Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace() with RandRange 1

Status
Not open for further replies.

DeZiner

Programmer
Joined
May 17, 2001
Messages
815
Location
US
Thanks for the previous help. I must say every post has worked perfectly so far. I am trying to combine setting a random record and then replacing occurences of ' with nothing.
Code:
<cfset recRand=RandRange(0, how_many.recordcount)>
			<cfset tempName=Replace(recRand,&quot;'&quot;,&quot;&quot;)>
then
Code:
<a href=&quot;[URL unfurl="true"]http://www.mydomain.com/detail.cfm?id=#how_many.id[/URL][recRand]#&quot; onMouseover=&quot;window.status=('#how_many.name[tempName]#'); return true&quot;>#how_many.name[recRand]#</a>
I have tried several combinations of what to replace. Am I even close here?

Thanks again.
DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
Based on

<cfset recRand=RandRange(0, how_many.recordcount)>
<cfset tempName=Replace(recRand,&quot;'&quot;,&quot;&quot;)> ,

recRand is a number. So I don't quite see why you'd find a &quot;'&quot; in a number.

The syntax for replace is:
Replace(string, substring1, substring2 [, scope ])

where string is any string (your recRand, which is a number) and substring1 is the occurance that you want replaced and substring2 is the string that should replace occurrencs of substring1.

I hope this helps. I'll look at your post again to see if I can devise something more like what you want.

John Hoarty
jhoarty@quickestore.com
 
I get it! OK, I want to actually replace how_many.name to remove the ' It's the names thing. Can you advise? DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
<cfset recRand=RandRange(0, how_many.recordcount)>

<cfoutput>

<cfset tempName = Replace(#how_many.name[recRand]#,&quot;'&quot;,&quot;&quot;)>

<a href=&quot;[recRand]#&quot; onMouseover=&quot;window.status=('#tempName#'); return true&quot;>#how_many.name[recRand]#</a>

Thank You! I figured it out.
How do I compensate for multiple replacements ie: replace ' @ % and ^ with nothing?


DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
Sure. To do that (on a randomly chosen record?), you were all over it:

How about,

<cfquery etc ... name=&quot;countemup&quot;>
SELECT COUNT(*) FROM nameTable
</cfquery>


<cfquery etc ... name=&quot;grabaname&quot;>
SELECT * FROM nameTable
WHERE id = #RandRange(0, countemup.recordcount)#
</cfquery>

<cfset tempName = replace(grabaname.name, &quot;'&quot;, &quot;&quot;)>

That help? Be sure you have a record for every integer from 1 to recordcount, inclusive, or you'll need to further test for the existence of that record or something.

John Hoarty
jhoarty@quickestore.com
 
I think you'd use Replacelist(how_many.name, &quot;@,%,^&quot;, &quot;&quot;)
and I think you could also use

REReplace(&quot;how_many.name&quot;,&quot;@|%|^&quot;,&quot;&quot;,&quot;ALL&quot;) John Hoarty
jhoarty@quickestore.com
 
You all Kick Ass... DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top