ASP/JScript

E

Excel User

Hi,

I using ASP/JScript and have the following but receive an error 'Object
Required'

myvalue = Request("value");
myvalue = UCase(myvalue);

Any ideas - I familiar with ASP/VBS but not ASP/JScript

Thanks
 
M

MightyChaffinch

Excel said:
Hi,

I using ASP/JScript and have the following but receive an error 'Object
Required'

myvalue = Request("value");
myvalue = UCase(myvalue);

Any ideas - I familiar with ASP/VBS but not ASP/JScript

Something like:
var myvalue = String (Request ("value"));
myvalue = myvalue.toUpperCase (); // assuming not null

MC
 
E

Excel User

Thanks MC - that's great!

MightyChaffinch said:
Something like:
var myvalue = String (Request ("value"));
myvalue = myvalue.toUpperCase (); // assuming not null

MC
 
E

Evertjan.

MightyChaffinch wrote on 15 sep 2009 in
microsoft.public.inetserver.asp.general:

Use var for new variables

do not use "value" as a input name in html forms

Never use the whole request object,
you could end up with nasty surprises, so:


var myvalue = Request.form("myValue");

or

var myvalue = Request.querystring("myValue");


That is VBS, not JS
Something like:
var myvalue = String (Request ("value"));
myvalue = myvalue.toUpperCase (); // assuming not null

Request.form() and Request.querystring()
always return a string, I think,
never a null. No conversion necessary.

var myValueUpper = Request.form("myValue").toUpperCase();
 
M

MightyChaffinch

Evertjan. said:
MightyChaffinch wrote on 15 sep 2009 in
microsoft.public.inetserver.asp.general:


Use var for new variables

do not use "value" as a input name in html forms

Never use the whole request object,
you could end up with nasty surprises, so:


var myvalue = Request.form("myValue");

or

var myvalue = Request.querystring("myValue");



That is VBS, not JS


Request.form() and Request.querystring()
always return a string, I think,
never a null. No conversion necessary.

I've had datatype problems using various parts of ASP & ADO from JScript
- I've adopted a defensive approach as a result.

The String (...) construct tells tells the script engine I want a
string, and tells me it's a string. I'll stick with it but YMMV...

MC
 
E

Evertjan.

MightyChaffinch wrote on 16 sep 2009 in
microsoft.public.inetserver.asp.general:
I've had datatype problems using various parts of ASP & ADO from JScript
- I've adopted a defensive approach as a result.

The String (...) construct tells tells the script engine I want a
string, and tells me it's a string. I'll stick with it but YMMV...

There is a difference between what you do yourself
and what is reasonable to advice in this NG.

Request.form() and Request.querystring() are not part of JS or VBS,
but ASP-platform functionalities.
They always return a [perhaps empty] string, as is simple to test.
 
E

Evertjan.

Dave Anderson wrote on 18 sep 2009 in
microsoft.public.inetserver.asp.general:
Evertjan. said:
Request.form() and Request.querystring() are not part of JS or VBS,
but ASP-platform functionalities.
They always return a [perhaps empty] string, as is simple to test.

They return neither, unless you capitalize them. And then they return
objects. If you really want the string value, use this:

You are partly right, Dave:

Request needs a capital.

Form and Item do not
Request.Form("elementname").Item
Request.QueryString("elementname").Item

Response.wriTe(Request.querysTriNg("a").item);

works fine here, but:

Response.wriTe(Request.queryString("a").iTem);

does not.
And then they return objects.

Objects that default to a string, if the there is only one,
otherwise to a collection. [how strange of the Original Programmers]
You can, of course, also examine:

Request.Form("elementname").Count
Request.QueryString("elementname").Count

True [? true]
 
E

Evertjan.

Dave Anderson wrote on 19 sep 2009 in
microsoft.public.inetserver.asp.general:
Evertjan. said:
And then they return objects.

Objects that default to a string, if the there is only
one, otherwise to a collection. [how strange of the
Original Programmers]

They do not "default to" strings. They have default properties that
are strings, and once you try using them outside the friendly confines
of the Response Object, you will understand that this is worthless
information in a JScript environment.

I don't understand.

Defaulting allways is with respect to use.

if (Request.querystring('elementname')=='')
// the above is outside the Response object, as you put it.
Response.wRIte('empty or absent');
Given:
var myValue = Request.QueryString("elementname")

Compare:
Response.Write(myValue)
Response.Write(myValue.length)

You claim it's a string. Why doesn't it have a length?

I do not claim ir IS a a string,
I claim it defaults to a string [unless it is a collection]

Your second example:

Response.Write(myValue.length);

is a non default use by definition.
this is worthless information in a JScript environment.

It seems it is valuable information in yours.
 
E

Evertjan.

Dave Anderson wrote on 22 sep 2009 in
microsoft.public.inetserver.asp.general:
By whose definition?

Mine, of course. What a question.
If, as you claim, it "defaults" to a string, then
that string will have properties. In JScript, [length] is one of those
properties. Would you prefer this to make it more "defaulty"?

You are wrong in my definition.

A dom example:

if window.location defaults to window.location.href

that does not mean

window.location.hash acts as window.location.href.hash

or

window.location.search acts as window.location.href.search

But feel free to define "defaults otherwise, Dave.
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top