• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

alert msg on onchange event

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,

Good afternoon to all from India.

I have a problem.

I have 4 dynamic dropdowns with same values.

Want to validate with each other so that the similar value will not be chosen by the user.If the user choses the same value it alerts "you have already chosen the value please select another one"

Means dropdown1 value cannot be same as dropdown2/3/4 and vice versa.
If somebody tries it shows the error.

I have written a function on the onchange of the every dropdown.
The alert is coming but is not coming accordingly.
I think I am not written the logic properly.

src_facility1,src_facility2,src_facility3,src_facility4 are 4 dropdowns

function facility()
{
if (document.form1.src_facility1.value==document.form1.src_facility2.value)
{
alert("You have already chosen this please select another")
document.form1.src_facility1.focus();
return false;
}
if (document.form1.src_facility1.value==document.form1.src_facility3.value)
{
alert("You have already chosen this please select another")
document.form1.src_facility1.focus();
return false;
}
if (document.form1.src_facility1.value==document.form1.src_facility4.value)
{
alert("You have already chosen this please select another")
document.form1.src_facility1.focus();
return false;
}
if (document.form1.src_facility2.value==document.form1.src_facility1.value)
{
alert("You have already chosen this please select another")
document.form1.src_facility2.focus();
return false;
}
if (document.form1.src_facility3.value==document.form1.src_facility2.value)
{
alert("You have already chosen this please select another")
document.form1.src_facility3.focus();
return false;
}
if (document.form1.src_facility3.value==document.form1.src_facility1.value)
{
alert("You have already chosen this please select another")
document.form1.src_facility3.focus();
return false;
}
if (document.form1.src_facility4.value==document.form1.src_facility3.value)
{
alert("You have already chosen this please select another")
document.form1.src_facility4.focus();
return false;
}
if (document.form1.src_facility4.value==document.form1.src_facility2.value)
{
alert("You have already chosen this please select another")
document.form1.src_facility4.focus();
return false;
}
if (document.form1.src_facility4.value==document.form1.src_facility1.value)
{
alert("You have already chosen this please select another")
document.form1.src_facility4.focus();
return false;
}
}
 
Sheriff
Posts: 67642
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"snp raj",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
author
Posts: 4323
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"snpraj"

Your name is still not a valid JavaRanch name. Please correct it right away. This is your second warning.

Scott Selikoff
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic