• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Javascript Dynamic Dropdown Box validation

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

I need a JavaScript Validation for Dynamic Drop Down Box when clicking the submit button. But the drop down box attribute name and id should be same for all drop down boxes. I tried below code but its not succeeded, its work well when there are multiple drop down box but its does not work when there is only one drop down box. Please help me for find out this problem or give me any suggestion without changing of attribute name and id of drop down box.




Thanks in Advance,

Prasath Arjunan.
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Id should be unique, why would you want to have the same id for different elements?
 
Prasath Arjunan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, it should not be unique...both id and name, because i cant generate unique id.
 
Albareto McKenzie
Ranch Hand
Posts: 312
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, really, it should be unique, other thing is that you don't want to make it unique, but imagine you are going to travel by plane and another guy has the same ticket number that you have, what happends?

A workarround if you want to do it this way is use the getElementsByTagName('select') but I would try to have unique ids as I have told you before.
 
Sheriff
Posts: 67746
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
If your ids are not unique, your HTML is invalid and you will have nothing but endless troubles.

Your id values must be unique!
 
Prasath Arjunan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks a lot... I have resolved this solution with the getElementsByTagName('select')
 
Do not meddle in the affairs of dragons - for you are crunchy and good with ketchup. Crunchy tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic