VBScript within Server side code?

Results 1 to 3 of 3

Thread: VBScript within Server side code?

  1. #1
    Join Date
    Dec 1969

    Default VBScript within Server side code?

    I am working with Database fields, hence server side script, but I have the need to use a VB replace statement. The database field contains carriage controls, so I want to replace them with an html &#060;p&#062;. Syntactically, I am getting type mismatches. So I thought that the statement which I know works on the client side might need to run on the client! This is the code I am trying to get working:<BR>&#060;% <BR>.....<BR>prevdescrip = Rs("Event_descript")<BR>If len(replace(replace(prevdescrip,chr(13),"&#060;p&# 062;"),char(10),"")) &#062; 0 then Response.Write strevdescrip & vbCrLf<BR>End if<BR>Response.Write strevdescrip & vbCrLf<BR>....<BR>%&#062;<BR><BR>The above code is used within a loop to write to the browser. Do I need to enter client side script? If so, how?<BR>

  2. #2
    SPG Guest

    Default It's just a typeo...

    ..."&#060;p&#062;"), chAr(10), ...<BR><BR>I don&#039t think you really wanted that A there.<BR><BR>HiH.

  3. #3
    Join Date
    Dec 1969

    Default RE: VBScript within Server side code?

    You&#039ve done a great job. But I&#039d guess you are familiar with Java or C++ or JavaScript. And you expect that "Replace" is a method that operates on the string it is given.<BR><BR>Nope. Replace is a function that returns a *NEW* string.<BR><BR>So when you do:<BR><BR>If Len(Replace(str,v1,v2)) &#062; 0 Then Response.Write str<BR><BR>you are writing the *original* string, which remains unaltered by the Replace call!<BR><BR>**********<BR><BR>In addition to that: You don&#039t show what you set the variable "strevdescrip" to. In the code you show, it is set to nothing, so presumably nothing is written by the Response.Write.<BR><BR>Did you mean for one of the two Response.Write calls to pick up the fixed-up-string?<BR><BR>************<BR><BR>You just need to do *something* like this:<BR><BR>prevdescrip = Rs("Event_descript")<BR>fixeddescrip = replace(replace(prevdescrip,vbCR,"&#060;p&#062;"), vbLF,"")) <BR>If len(fixeddescrip) &#062; 0 then Response.Write fixeddescrip & vbCrLf<BR>End if<BR>Response.Write strevdescrip & vbCrLf &#039 ??? what is this ???<BR><BR>************<BR><BR>NOTE: I used the predefined VBS constants vbCR and vbLF in place of your chr() calls because each call to chr has to actually execute the function call, dynamically allocate a new string, etc. Pretty much a time waster.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts