473,513 Members | 2,469 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Compare two dropdowns in ASP.NET

8 New Member
Hi,
How can i compare values of two dropdown lists in .aspx page using javascript?

I used following code-
Expand|Select|Wrap|Line Numbers
  1.  
  2. function ValidateFlightRequest()
  3. {
  4.         var vFromCombo = igcmbo_getComboById("ctl00_SearchBar1_ddlLeftsearchFrom");
  5.  
  6.        var vToCombo = igcmbo_getComboById("ctl00_SearchBar1_ddlLeftsearchTo");
  7.  
  8.        if(vFromCombo.getSelectedIndex() == vToCombo.getSelectedIndex())
  9.        {
  10.             alert("From Airport and two airport cann't be same");
  11.             return false;
  12.        }
  13. }
Jun 29 '07 #1
1 2219
Frinavale
9,735 Recognized Expert Moderator Expert
Hi,
How can i compare values of two dropdown lists in .aspx page using javascript?

I used following code-
Expand|Select|Wrap|Line Numbers
  1.  
  2. function ValidateFlightRequest()
  3. {
  4.         var vFromCombo = igcmbo_getComboById("ctl00_SearchBar1_ddlLeftsearchFrom");
  5.  
  6.        var vToCombo = igcmbo_getComboById("ctl00_SearchBar1_ddlLeftsearchTo");
  7.  
  8.        if(vFromCombo.getSelectedIndex() == vToCombo.getSelectedIndex())
  9.        {
  10.             alert("From Airport and two airport cann't be same");
  11.             return false;
  12.        }
  13. }
Hi Ganeshshegde!
Welcome to theScripts, I hope you like it here!

Why would you want to do this using JavaScript?
Please note that people can easily by-pass JavaScript checks and submit invalid data to mess up your program.

Anyways, I would do this check server side on button click.
If it the arports match you could just set an error message in a label instead of using a JavaScript alert box.

Is it absolutely necessary to use JavaScript for this?

-Frinny
Jun 29 '07 #2

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

Similar topics

0
2701
by: Phil Powell | last post by:
/*-------------------------------------------------------------------------------------------------------------------------------- Parameters: $formField1: The name of the first array $formField2: The name of the second array $formField1CompareWith: String to use as my comparison basis for first array. Defaults to using $val unless it's 'key'...
2
1920
by: Crescionini Sascha | last post by:
Hello NG If I let appear a DIV over a HTML site with dropdowns, this dropdowns are still visible. Is there a way to push them to the back? All other form elements arent visible. greets sascha
16
4412
by: michael | last post by:
Is it possible to get all href URLs contained in a unordered list and place them in an array? Or in fact two different arrays, differently named one for each <ul> group? <ul> <li><a href="lemurs.html">Lemurs</a></li> <li><a href="chameleons.html">Chameleons</a></li> </ul> <ul>
3
1568
by: Damon | last post by:
I am working on a site in which I would like to have two dropdowns that will allow a user to navigate through the administrative pages of the site. The first would allow the user to choose the particular site that they would like to edit. The second would allow the user to select which admin screen they would like to edit. The second dropdown...
1
1458
by: Andy | last post by:
What I want to do is to populate multiple dropdowns when editing. Presumably... a) I should use a DataReader so that I can get each ResultSet for each dropdown control, and that should cut down round trips to the server. b) I should populate these dropdowns in the DataGrid_EditCommand? What I am having problems with is actually referencing...
3
1209
by: Simon Harvey | last post by:
Hi everyone, I keep getting a problem with dropdownlist controls. It sounds really stupid, but my app is screwed as long as this keeps happening. It seems to spontaneously happen and then I cant fix it without rebuilding the whole page from scratch! Not Fun. :-( So whats happening is I have my dropdowns on the page. The user comes along...
3
5998
by: HelpPlzz | last post by:
I want to compare the min and max values between two dropdowns. This script sometimes gives correct result ...and sometimes not... Pls can u answer me whts goin wrong sometimes. <html> <head> <script type='text/JavaScript'> function validateBox() {
0
1604
by: bogorman | last post by:
Am trying to add a "video" to a webpage which is based on a template containing a javascript menu. The site has hundreds of pages all based on this template and the menu works fine The page can be viewed: www.faith.org.uk/Testindex.html In IE7 it works fine. The video shows and the dropdowns of the menu work correctly. In Mozilla Firefox,...
0
957
by: sbart | last post by:
I am programing in asp.net vb using AjaxToolkit cascadingDropDown. I do not have access to AjaxToolkit cascading dropdown event handlers. I have a series of dropdowns. The selection from one of the dropdowns (call it ddA) triggers the visibility of some of the other dropdowns. Problem is that f the user makes one selection from ddA, makes...
0
7177
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7394
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. ...
0
7559
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...
1
7123
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...
0
7542
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...
0
5701
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4756
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...
0
3237
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.