473,811 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Redire ct method from the page checking the
submition.
When I do that I call the page with a parameter like this
Response.Redire ct("Page.asp?FR OM=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.QuerySt ring("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 4743
"Ophir" <op*****@netvis ion.net.il> wrote in message
news:ec******** *************** ***@posting.goo gle.com...
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.Redire ct method from the page checking the
submition.
When I do that I call the page with a parameter like this
Response.Redire ct("Page.asp?FR OM=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.QuerySt ring("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.QueryS tring() != "") {
from_flag = Request.QuerySt ring("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.602 872$8_6.435612@ attbi_s04>...

How about:

var from_flag = "";
if (Request.QueryS tring() != "") {
from_flag = Request.QuerySt ring("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("FR OM"))

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
2225
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 where the user gets 1 question at a time and it keeps scoring until the end and gives a summary and I want to do it only in JavaScript (no ASP, PHP, JSP, etc). I tried submitting the quiz page to itself using a query string to keep track of...
1
1641
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' Frame.. Worst(yesyes!!) 1 - Explorer 6 : clicking a link in the 'menu' frame simple reopens an instance of the FRAMESET, syntax error msg. 2 - Netscape 7.1 : clicking a link in the 'menu' frame simple reopens
1
2216
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', 'status=yes,height=200,width=450,top=10,left=10,scrollbars=yes'); } function updatestats (icount,smessage,iupdate,tcount) { //var scanStatus = scanWindow.document.form1; alert('scanWindowCheck sc= ');
49
14566
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 http://www.webreference.com/programming/javascript/gr/column9/ they say: <snip> The undefined property A relatively recent addition to JavaScript is the undefined property.
6
5586
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 object collection and stanrd using it it starts to fall apart. Clearly there is something about javascript's usage of passing "By ref" that i am not getting. i have had a look on the web and found some examples, but i cant see why my code does not...
7
16276
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 javascript and make it work with asp. Any thought, ideas or pointers in the right direction would be greatly appreciated. I am getting the following error: Microsoft JScript runtime error '800a1391'
45
4868
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 "new Array() vs " question or to the array performance, I dared to move it to a new thread. Gecko takes undefined value strictly as per Book 4, Chapter 3, Song 9 of Books of ECMA :-)
6
2337
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 and provides a mechanism to encode/decode them. However I can't seem to get it to work: .... <asp:textbox id=txtDescription style="Z-INDEX: 102; LEFT: 111px; POSITION: absolute; TOP: 124px" tabIndex=29 runat="server" onblur="return...
2
2471
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.... menuitems.js mmenu.js
0
9728
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10648
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10389
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10402
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10135
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7670
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6890
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3867
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.