Server Side Javascript

Server Side Javascript

am 30.05.2007 21:34:23 von Simon Harris

Hi All,

I have just taken on maintenance of an app developed in ASP with JavaScript
as the language.

I am struggling with carrying out some math on a value derived from the
querystring:

if (Request.QueryString != "") {
nPage = Request.QueryString("Page");
} else {
nPage = 1;
}

How do I program this so that nPage is an integer, rather than a string when
it comes from the querystring? I have tried this:

....
nPage = cInt(Request.QueryString("Page"));
....

This results in the following error:
Microsoft JScript runtime error '800a138f'
Object expected

If I don't do this, when I use the variable nPage later on (To add it to
another number) I get NaN error. (Not a number - E.g Trying to add a string
to a number)

Any help will be much appreciated.

Thank you.

Simon.

--
--
* Please reply to group for the benefit of all
* Found the answer to your own question? Post it!
* Get a useful reply to one of your posts?...post an answer to another one
* Search first, post later : http://www.google.co.uk/groups
* Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!

Re: Server Side Javascript

am 30.05.2007 22:03:38 von Tim Slattery

"Simon Harris" wrote:

>Hi All,
>
>I have just taken on maintenance of an app developed in ASP with JavaScript
>as the language.
>
>I am struggling with carrying out some math on a value derived from the
>querystring:
>
>if (Request.QueryString != "") {
> nPage = Request.QueryString("Page");
>} else {
> nPage = 1;
>}

nPage = parseInt(Request.QueryString("Page"));


> nPage = cInt(Request.QueryString("Page"));
>...
>
>This results in the following error:
> Microsoft JScript runtime error '800a138f'
> Object expected

Yup. cInt is a VBScript function. JScript doesn't knkow what it is.

--
Tim Slattery
MS MVP(DTS)
Slattery_T@bls.gov
http://members.cox.net/slatteryt

Re: Server Side Javascript

am 31.05.2007 00:15:26 von Simon Harris

Tim - Thank you! :o)

"Tim Slattery" wrote in message
news:u2mr535b9smciich3lcpbb941uj4demso6@4ax.com...
> "Simon Harris" wrote:
>
>>Hi All,
>>
>>I have just taken on maintenance of an app developed in ASP with
>>JavaScript
>>as the language.
>>
>>I am struggling with carrying out some math on a value derived from the
>>querystring:
>>
>>if (Request.QueryString != "") {
>> nPage = Request.QueryString("Page");
>>} else {
>> nPage = 1;
>>}
>
> nPage = parseInt(Request.QueryString("Page"));
>
>
>> nPage = cInt(Request.QueryString("Page"));
>>...
>>
>>This results in the following error:
>> Microsoft JScript runtime error '800a138f'
>> Object expected
>
> Yup. cInt is a VBScript function. JScript doesn't knkow what it is.
>
> --
> Tim Slattery
> MS MVP(DTS)
> Slattery_T@bls.gov
> http://members.cox.net/slatteryt

Re: Server Side Javascript

am 31.05.2007 04:22:35 von Dave Anderson

"Simon Harris" wrote:
> I have just taken on maintenance of an app developed in ASP with
> JavaScript as the language.
^^^^^^^^^^

> nPage = cInt(Request.QueryString("Page"));

Obviously, this is VBScript. You probably want something like:

nPage = +Request.QueryString("Page").Item || 1 // 1 is default


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.