Notices
Non Scooby Related Anything Non-Scooby related

Active Server Pages question

Thread Tools
 
Search this Thread
 
Old 21 May 2001, 08:27 PM
  #1  
DazV
Scooby Regular
Thread Starter
 
DazV's Avatar
 
Join Date: Jun 2000
Posts: 3,783
Likes: 0
Received 0 Likes on 0 Posts
Post

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).]
Old 21 May 2001, 09:21 PM
  #2  
DazV
Scooby Regular
Thread Starter
 
DazV's Avatar
 
Join Date: Jun 2000
Posts: 3,783
Likes: 0
Received 0 Likes on 0 Posts
Post

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

Let me know if there's a better way.

-DV
Old 21 May 2001, 09:44 PM
  #3  
Mr.Cookie
Scooby Regular
 
Mr.Cookie's Avatar
 
Join Date: Apr 2000
Location: www.mrcookie.co.uk
Posts: 5,757
Likes: 0
Received 0 Likes on 0 Posts
Post

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
Old 21 May 2001, 09:58 PM
  #4  
DazV
Scooby Regular
Thread Starter
 
DazV's Avatar
 
Join Date: Jun 2000
Posts: 3,783
Likes: 0
Received 0 Likes on 0 Posts
Post

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
Old 21 May 2001, 10:52 PM
  #5  
kryten
Scooby Regular
 
kryten's Avatar
 
Join Date: May 2000
Posts: 869
Likes: 0
Received 0 Likes on 0 Posts
Post

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
Old 22 May 2001, 08:19 AM
  #6  
chiark
Scooby Regular
 
chiark's Avatar
 
Join Date: Jun 2000
Posts: 13,735
Likes: 0
Received 0 Likes on 0 Posts
Post

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

So

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

Will give <A HREF="*****.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") & """>"

Nick.
Old 22 May 2001, 12:34 PM
  #7  
DazV
Scooby Regular
Thread Starter
 
DazV's Avatar
 
Join Date: Jun 2000
Posts: 3,783
Likes: 0
Received 0 Likes on 0 Posts
Post

Cool Kryten - will give it a try!

-DV
Old 22 May 2001, 12:48 PM
  #8  
DazV
Scooby Regular
Thread Starter
 
DazV's Avatar
 
Join Date: Jun 2000
Posts: 3,783
Likes: 0
Received 0 Likes on 0 Posts
Post

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
Old 22 May 2001, 01:06 PM
  #9  
DazV
Scooby Regular
Thread Starter
 
DazV's Avatar
 
Join Date: Jun 2000
Posts: 3,783
Likes: 0
Received 0 Likes on 0 Posts
Post

Cheers Nick - thats a great tip.

-DV
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
KAS35RSTI
Subaru
27
04 November 2021 07:12 PM
Rbon91
ScoobyNet General
49
21 November 2018 03:23 PM
Frizzle-Dee
Essex Subaru Owners Club
13
01 December 2015 09:37 AM
south_scoob
ScoobyNet General
22
03 October 2015 01:05 PM
Brzoza
Engine Management and ECU Remapping
1
02 October 2015 05:26 PM



Quick Reply: Active Server Pages question



All times are GMT +1. The time now is 02:41 AM.