i have html that is stored in a database for one part of a site.. so when <%=rsText("text")%> is written it writes to screen the html when there is links in this html they show fine but i want to add something to the link... ie ?id=1 is there a way of doing this? I want to do it in the asp page as this will be used as a template and the id will change so to clarify one part of the html stored in the database may have.. <a href="/content/test/File/red/Pontus/test.asp">test</a> which will show test as a link but i want to add in ?id=1 but not to the database code... please help thanks
make a function in asp that will add ur numbers and call it from asp so you could have <%=MyFunc(rsText("text"))%> and my func would be like this sub myFunc(str) myFunc = str & "1" end Sub
So, you've written the whole anchor into the database? Hmmm... That make it a little harder to work with... It would make more sense (to me!) if you stored the file name in the DB as it would be easier to manipulate the link this way... This will work though: <%= Replace(rsText("text"), ".asp", ".asp?id=1") %>
i think you missed the point.. for example rsText("text") could be <p> The products we are importing are red, white and sparkling wines. We do also import cognacs, grappas and local spirits. Today we have partnerships with award winning wineyards located in Spain, Italy, France and Greece. </p> <p> For more information, please <a target="_parent" href="../info/">contact us</a>.</p> Code (markup): I only need to add the ?id=1 to the ahref so it would be ../info/?id=1 make more sense?
I explain with an example i have three sites say roger sam paul roger has a siteid of 1, sam a siteid of 2 and paul of 3 and within the text stored in the database thier maybe three links strText = "Hello there, please visit <a href=""/sites/roger/about/about.asp"">roger about</a> or <a href=""/sites/paul/products.asp"">sam product</a> or <a href=""http://www.jacintotrading.com"">jacintotrading</a> " the first link will need a ?id=1 the second will need a ?id=3 and the last no ?id does this make sense?
This will still work: <%= Replace(rsText("text"), """>", "?id=1"">") %> Edit - sorry, now it won't You could split the string on say, "</a>" giving you: array(0) "Hello there, please visit <a href=""/sites/roger/about/about.asp"">roger about" array(1) "or <a href=""/sites/paul/products.asp"">sam product" array(2) "or <a href=""http://www.jacintotrading.com"">jacintotrading" array(3) "" Then loop through your new array and update each part: For x = 0 to Ubound(array) If array(x) <> "" Then newstr = newstr & Replace(rsText("text"), """>", "?id=" & (x+1) & """>") & "</a> " End If Next
ok, i am going to change the way i do it.... i am going to add the id before i post to the database.. so i need now to get the request.form item so <%=request.form("postedTextFromEditor")%> which returns <p> <a href="/cm/website/File/roger/test.asp">he</a>is a young innovative man. </p> <p>Today we have partnerships with award winning wineyards located in Spain, Italy, France and Greece. </p> <p> For more information, please <a href="/cm/website/File/maincontact/contact.asp" target="_parent">contact us</a>.</p> i will now need to somehow return the words roger and maincontact so that i can find the site ids for them then will need to add a ?siteid='number' to here so that when the link is stored its stored with correct id a count wont work as id needs to come from db..
You can find words roger and maincontact if you find the location of first occurance of "/" after the word File & the location of "/" afterwards. I've done it before by stripping the string, however here it's not needed believe me, I think you are doing something the hard way.......try redesigning your db structure instead of creating functions when you can live without them (in this case I believe).
I think I agree with NFS - you're not going to find a simple solution to this, and it would be much better not to have to pass the querystring such as id=1 Why do you need it? Why doesn't the page '/cm/website/File/roger/test.asp' know that it is number 1 without needing to be told by a querystring?
it needs that id=1 or what ever cause this is the site id and this is the main table in the database ie i use two or three templates and when a page is created it is copied and renamed to the location of the site files. there is a dbcall at the top of the page that asks for the site id so that it can get the data