473,320 Members | 1,978 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,320 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 4717
"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.... ...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.