473,387 Members | 1,541 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,387 software developers and data experts.

Javascript if... else... producing same no matter what the value

I'm working with ASP.NET 1.1 and I am attempting to compare the value of a textbox on the pages onunload event. The screen that is open is a pop-up screen that can be opened from links on two different pages. What i want to do is cause a post back to the form from which the pop-up screen originated.
Here is my code:
Expand|Select|Wrap|Line Numbers
  1. <script language="javascript" type=text/javascript>
  2. //If the window is closed
  3. function doUnload(){
  4. if (window.event.clientX < 0 && window.event.clientY < 0)
  5. {
  6.     var Division = '' + document.forms(0).txtDivisionCode.value + '';
  7.     if (document.forms(0).txtScreen.value = 'Division'){        
  8.          window.opener.location = '../Maintenance/Divisions.aspx';
  9.     }
  10.     else {
  11.         UpdateAcctEditScreen(Division);
  12.     }
  13. }
  14. }
  15. </script>
  16. ...
  17. <body onunload="doUnload()">
The window.opener.location routine works fine in that it sucessfully loads the Divisions form. However, it does this no matter what the value of the txtScreen textbox is. It seems the Javascript is not performing the if statement correctly. Any help is appreciated. Thanks.
Mar 24 '08 #1
1 1242
pronerd
392 Expert 256MB
You need to use a double equals sign (==) in an if condition.

This is just setting the value of document.forms(0).txtScreen.value to 'Division'
Expand|Select|Wrap|Line Numbers
  1. document.forms(0).txtScreen.value = 'Division'
To test to see if the two values are equal it would need to be :
Expand|Select|Wrap|Line Numbers
  1. document.forms(0).txtScreen.value == 'Division'
Mar 24 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
11
by: George Hester | last post by:
I have a css file this is a portion of it: /* trackaccept.css */ div.track { width:400px; height: 100px; } I have this in my ASP page:
53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
1
by: cheezebeetle | last post by:
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when...
6
by: Dan Webb | last post by:
Hi All, Im currently working on ways of pacakaging javascript functions/variables/objects in a similar way to the Java package statement so that scripts can be interact with each other with the...
35
by: VK | last post by:
Whatever you wanted to know about it but always were affraid to ask. <http://www.geocities.com/schools_ring/ArrayAndHash.html>
15
by: binnyva | last post by:
Hello Everyone, I have just compleated a JavaScript tutorial and publishing the draft(or the beta version, as I like to call it) for review. This is not open to public yet. The Tutorial is...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
1
by: charales | last post by:
Hi everyone! I'm having this problems with javascript. If you go to: http://www.nikonistas.com/es_home/nikon2.html you'll find at the top-left corner the typical username-password form with the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.