ScoobyNet.com - Subaru Enthusiast Forum

ScoobyNet.com - Subaru Enthusiast Forum (https://www.scoobynet.com/)
-   Non Scooby Related (https://www.scoobynet.com/non-scooby-related-4/)
-   -   Active Server Pages question (https://www.scoobynet.com/non-scooby-related-4/17319-active-server-pages-question.html)

DazV 21 May 2001 08:27 PM

Anyone help - came across a problem today:

Trying to insert a recordset's field content into an HTML tag eg.

response.write "<A HREF=search.asp?textbox_category=" & recordset_search_results(1) & ">" & recordset_search_results(1) & "</A>"

Trouble is, if the recordset_search_results contains spaces (eg. plant engineers) it won't pick them up - it'll only insert plant into the tag.

I've tried converting it to a string and inserting that instead but I get the same results.

I've a feeling I may have to strip the spaces out manual and fill them with + instead - tell me there's a better way!

Any ideas ?

-DV

[This message has been edited by DazV (edited 21 May 2001).]

DazV 21 May 2001 09:21 PM

Sorted - I've used the cheap and cheerful command 'replace' to do the job.

Let me know if there's a better way.

-DV

Mr.Cookie 21 May 2001 09:44 PM

Daz i dont know alot about html and dont really understand what your doing, but with urls and linking them if there a space i have to put in %20.

Si

DazV 21 May 2001 09:58 PM

Cheers Mr Cookie.

I think the problem is, if you ever try and pass a parameter in a hyperlink, and the parameter is string variable, you must ensure the string has no spaces in it.

eg. Dark Blue Mica, must be converted into Dark+Blue+Mica for it to work.

All sorted.

-DV

kryten 21 May 2001 10:52 PM

Not 100% certain as I'm currently away from my ASP books but I think that server.urlencode (str) will do the encoding for you....

no flames please if it doesn't http://bbs.scoobynet.co.uk/smile.gif

chiark 22 May 2001 08:19 AM

Just for the sake of completeness, you can also embed double quotes in ASP code..

So

response.write "<A HREF=""balls.htm"">"

Will give <A HREF="balls.htm"> as output

A pair of double quotes is interpreted as meaning "put a double quote in the string".

It can get messy when you get things like "<A HREF=""" & myrs("URL") & """>" http://bbs.scoobynet.co.uk/biggrin.gif

Nick.

DazV 22 May 2001 12:34 PM

Cool Kryten - will give it a try!

-DV

DazV 22 May 2001 12:48 PM

The deinitive answer (if there is such a thing). Simply add single quotes to the tag like this:

<A HREF=search.asp?textbox_category=" & recordset_search_results(1) & ">

now becomes:

<A HREF='search.asp?textbox_category=" & recordset_search_results(1) & "'>

So bloody simple (like most answers are!)

I'll get me coat...

-DV

DazV 22 May 2001 01:06 PM

Cheers Nick - thats a great tip.

-DV


All times are GMT +1. The time now is 03:49 AM.


© 2024 MH Sub I, LLC dba Internet Brands