VBscript and JScript

  • Thread starter Christopher Brandsdal
  • Start date
C

Christopher Brandsdal

Hi!

Maby this is wring newsgroup..

I'm using ASP / VBscript on my own cms system, but I needed to use some
jscript to make something work... I'm new to jscript, so here is a simple
question:

(1) I want to count how many characters there is in a string. In ASP I just
use <%=Len(Variabel)%> How do I do this in Jscript?

(2) How can I display only a numer of characters from a variabel or a
string? In ASP I use <%=Left(Variabel,20)%> How do I do this in Jscript?


THe code i use is part vbscript and jscript. Hope somone can help me
translate it to pure JScript :)


var dot

if(Len(oEventsList.GetBody()) > 20)
{
dot = "..."
}

Response.Write (Left(oEventsList.GetBody(),20) + dot + "<br><br>");


Thanks in advance!

Christopher Brandsdal
Norway
 
R

Ray at

Christopher Brandsdal said:
Hi!

Maby this is wring newsgroup..

I'm using ASP / VBscript on my own cms system, but I needed to use some
jscript to make something work... I'm new to jscript, so here is a simple
question:

(1) I want to count how many characters there is in a string. In ASP I just
use <%=Len(Variabel)%> How do I do this in Jscript?

In jscript, strings are objects. You'd use the length property of the
object as so:

<%@ Language=JScript %>
<%
var x = "hi there."
Response.write(x.length)
%>

(2) How can I display only a numer of characters from a variabel or a
string? In ASP I use <%=Left(Variabel,20)%> How do I do this in Jscript?

<%
var x = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Response.write(x.substr(1,20))
%>


You can download the WSH documentation (which includes the jscript
documentation) here.
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9

Or view the string object info here.
http://msdn.microsoft.com/library/en-us/script56/html/js56jsobjstring.asp

I think Microsoft did a great job on their scripting documentation.

Ray at work
 
R

Ray at

You already had your answer from another group and were on your way with it
when I took time out of my day to answer your questions for you. This is
bothersome. Please do not multipost.

Ray at work
 
C

Christopher Brandsdal

Sorry I will NEVER multipost again.
But thank you for wanting helping me!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top