473,287 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Problem with 'undefined' object In server side JavaScript

Hello all

I have this problem:
I'm displaying a loggin page.
If the user entered an invalid UserName/Password I display the page
again.
When this happens I want to give the user a different message then the
one
displayed when the page was initially displayed.

I use the Response.Redirect method from the page checking the
submition.
When I do that I call the page with a parameter like this
Response.Redirect("Page.asp?FROM=1").

When I get the parameter in the page I know I need to show a different
message.

The problem is that if the page is called without the parameter, I
cannot determine that the parameter is missing.
The codse is very simple:

from_flag = Request.QueryString("FROM")

Now is the problem -
if I use if(from_flag == 'undefined') - this condition return
false.
but if I display from_flag using Response.Write(from_flag) I get
"undefined"

if I use if(typeof from_flag == "undefined") - this does not work
since the typeof return "object" in both cases when I call the page
with the parameter or without the parameter.

also I tried to comnpare with null does not work.

By the way if I use VBScript as the script lang - it works fine I
just need to compare the from_flag with vbNullString and all is well.

How can I do it in JavaScript????
Jul 23 '05 #1
2 4715
"Ophir" <op*****@netvision.net.il> wrote in message
news:ec**************************@posting.google.c om...
Hello all

I have this problem:
I'm displaying a loggin page.
If the user entered an invalid UserName/Password I display the page
again.
When this happens I want to give the user a different message then the
one
displayed when the page was initially displayed.

I use the Response.Redirect method from the page checking the
submition.
When I do that I call the page with a parameter like this
Response.Redirect("Page.asp?FROM=1").

When I get the parameter in the page I know I need to show a different
message.

The problem is that if the page is called without the parameter, I
cannot determine that the parameter is missing.
The codse is very simple:

from_flag = Request.QueryString("FROM")

Now is the problem -
if I use if(from_flag == 'undefined') - this condition return
false.
but if I display from_flag using Response.Write(from_flag) I get
"undefined"

if I use if(typeof from_flag == "undefined") - this does not work
since the typeof return "object" in both cases when I call the page
with the parameter or without the parameter.

also I tried to comnpare with null does not work.

By the way if I use VBScript as the script lang - it works fine I
just need to compare the from_flag with vbNullString and all is well.

How can I do it in JavaScript????


How about:

var from_flag = "";
if (Request.QueryString() != "") {
from_flag = Request.QueryString("FROM");
}
(The above is pseudo code; I use VBScript for my ASP.)
Jul 23 '05 #2
"McKirahan" <Ne**@McKirahan.com> wrote in message news:<g32ld.602872$8_6.435612@attbi_s04>...

How about:

var from_flag = "";
if (Request.QueryString() != "") {
from_flag = Request.QueryString("FROM");
}
(The above is pseudo code; I use VBScript for my ASP.)


McKirahan thanks fore the reply
Your idea will not solve the problem, because if the QueryString will
not contain a "FROM" parameter but something else I will have to ask
later for the value of from_flag and again will be in the same
problem.

How ever I have found out that this solved the problem:

var from_flag = new String(Request.QueryString("FROM"))

if (from_flag == "undefined")
{
Do Somthing
}

This code works and if there is no FROM parameter passed to the page
from_flag gets to be undefined and the if works fine.

Thanks again
Ophir
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tim Simmons | last post by:
I am stumped. I encoded the action = of my form using GET and I can't seem to get the property/value stuff from it using a JavaScript script I got from the web. I want to create a trivia game...
1
by: Phil | last post by:
Supposedly, the code below should assign the correct value to the 'url' variable. But all I get is a blank 'main' Frame with apparently nowhere to go when I click on the link in the 'menu'...
1
by: s_m_b | last post by:
here's the code (running from an ASP page): <script language = "JavaScript" type="text/javascript"> function initStuff() { var scanWindow = window.open('scanning.htm', 'scanning',...
49
by: matty | last post by:
Hi, I recently got very confused (well that's my life) about the "undefined" value. I looked in the FAQ and didn't see anything about it. On...
6
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
7
by: dd | last post by:
Hello all. First, I'm a newbie to javascript but not to ASP. Secondly I've been searching for the answer for two hours and I decided to finally post this question. I'm trying to take a...
45
by: VK | last post by:
(see the post by ASM in the original thread; can be seen at <http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/3716384d8bfa1b0b> as an option) As that is not in relevance to...
6
by: teddysnips | last post by:
In my application I need to allow users to cut 'n' paste stuff from various sources, some of which might include dodgy characters such as "<". Natch, IE interprets these as potentially dangerous...
2
by: davidson1 | last post by:
Hai friends..for menu to use in my website..i found in one website....pl look below website.... http://www.dynamicdrive.com/dynamicindex1/omnislide/index.htm i downloaded 2 files.... ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.