Jump to content

disable buttons works for only one button - other two ( the same id ) still enabled


roberto68

Recommended Posts

I want to disable buttons when user do not choose category ind dropdown list - it works but only for one id the other ids with the same "name" are still enabled here's my code

 $(document).ready(function() {                 // Create the dropdown base      $("<select />").appendTo("nav");        $("#submit").attr('disabled','disabled'); // defaultne disabled        $("#dropdowns").change(function() {  // or keyup(function)        if($(this).val()===""){            $("#submit").removeAttr('disabled');                         } else {        $("#submit").attr('disabled','disabled');                                }                           });  .....
	<div class="mapbuttons" id="mapbuttons" >	<input type="button" value="add a place" id="submit" onclick="proceed('addplace')" />	<input type="button" value="add an event" id="submit" onclick="proceed('addevent')" />	<input type="button" value="show event" id="submit" onclick="proceed('showevent')" />	</div>	
Link to comment
Share on other sites

IDs have to be unique, you can't have multiple elements with the same ID. An alternative would be to give those buttons different IDs (or none if you don't need it somewhere else), but the same class name, and then target them by class name instead of ID.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...