Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 18th, 2005, 02:00 AM
Friend of Wrox
Points: 686, Level: 9
Points: 686, Level: 9 Points: 686, Level: 9 Points: 686, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: Kolkata, West Bengal, India.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cutting a character from a string

Hi everyone,

I have a peculiar problem where I have field called briefdesc in my table which contains description of a product. The description contains dimensions given in inches like 8" x 8" .I am retrieving the value of this field and sending it as a querystring in a hyperlink where there are other querystring values also.My problem is whenever the field is returning a value which has " in the string I'm getting a Javascript error message that there is an unterminated string and the hyperlink is not working. My hyperlink is like below:

----

<a href="javascript://" onclick="open_page(<%=rsproduct("id")%>,'<%=rsprod uct("name")%>','<%=rsproduct("briefdesc")%>','<%=r sproduct("minprice")%>','<%=rsproduct("image")%>', '<%=session("user")%>')" style="text-decoration:none">

-----

Whenever there is an error the querystring values after briefdesc cannot be read.

Is there any way out where I can handle ["] and somehow pass the querystring values or is there a method to trap the ["] from the sql query itself and store in a variable??


Any help will be great..
Thanks in advance.
  #2 (permalink)  
Old August 18th, 2005, 06:41 AM
Registered User
Points: 1,897, Level: 17
Points: 1,897, Level: 17 Points: 1,897, Level: 17 Points: 1,897, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: Mumbai, Maharastra, India.
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

Hi Arnab,

You can apply function while getting value from briefdesc. e.g.
<%=rsproduct("briefdesc")%> will be <%=StoreText(rsproduct("briefdesc"))%>

And function will be like:
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Function StoreText(theText)
    StoreText = ""
    on error resume next
    StoreText = CStr(theText)
    if (len(StoreText) > 0) Then
      StoreText = Replace(StoreText, """", "&quot;", 1, -1, 1)
      StoreText = Replace(StoreText, "'", "''", 1, -1, 1)
      StoreText = Replace(StoreText,"<","&lt;", 1, -1, 1)
      StoreText = Replace(StoreText,">","&gt;", 1, -1, 1)
      StoreText = Replace(StoreText, vbCrLf, "<BR>", 1, -1, 1)
    end if
End Function
--------------



Rupen Anjaria.:)
------------------
We CAN'T avoid problems, but can solve it.
  #3 (permalink)  
Old August 18th, 2005, 07:44 AM
Friend of Wrox
Points: 686, Level: 9
Points: 686, Level: 9 Points: 686, Level: 9 Points: 686, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: Kolkata, West Bengal, India.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Rupen,

That worked just as I had wanted.You saved me a headache. Thanks again.!!!


Similar Threads
Thread Thread Starter Forum Replies Last Post
string character conversion Neal XSLT 2 February 23rd, 2006 08:23 AM
newbie question- cutting a string apart harpua BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 June 21st, 2005 04:53 AM
Replacing a character from string itHighway Classic ASP Basics 5 March 14th, 2005 11:15 PM
Search for Character in String Kaynor09 Excel VBA 2 April 24th, 2004 11:13 AM
Wide Character String kochoo Classic ASP Components 0 October 12th, 2003 12:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.