View Full Version : replace html tag

01-02-2004, 02:51 PM
I have information in a database field that includes a url link ie:

Click <a href="news_view.asp?id=315">here</a>.

This information is used in 2 places, one is on the main site but the other is in a popup window - so I need it to say:

Click <a href="javascript:updateParent('news_view.asp?id=315')">here</a>

How can I use the asp, vbscript REPLACE to do something like:

replace (recordset.Fields.Item("fieldName").Value,
"<a href=""***"">",
"<a href=""javascript:updateParent('news'***')"">")

Where it ignores whatever the *** is and wraps the tag around it?


01-02-2004, 04:16 PM
in the database, are you storing the whole a href tag or are you only storing the url?

01-02-2004, 04:49 PM
the whole href. I could put identifier around the url like:


and do a replace on the start and then the end of the tag according to which page is using the information, but I want novice users to add information to the database via a rich text editor, which will add the href tags around the url (I dont have the rich text editor yet, we are in the process of purchasing one, so I may be able to edit the code this adds).

Your question has me thinking though!! was this along the lines of what you were thinking?!!


01-02-2004, 06:31 PM
Why not use VBScript's string manipulation functions to handle it ?

01-02-2004, 06:37 PM
It might be easier to work with if you only stored the URL in the database.

01-02-2004, 06:40 PM
Originally posted by oracleguy
It might be easier to work with if you only stored the URL in the database.

That is what I was hinting at
then you can just do put the output where you need it

<a href="<% blah %>">
<a href="javascript:HM('<% blah %>')">