jquery - How to only allow a list of dynamically added inputs not have the same number value chosen by the front end user -


i have dynamically created un ordered list. each list item has image input field type:number , label element. have javascript allowing user enter number 1-10; want allow user give each image unique rating, in other words user couldn't rate 2 images both 9.

example of list

this jquery code append images select when checked in different section:

$('#confirm').click(function(){    $('#checkedimagecontainer').removeclass('hidden');     $(this).prop('disabled', true);     $("input[name='tool']").each(function () {       if( $(this).is(':checked') ){         $('.checkedimagelist').append('<li>            <img src="' + $(this).parent('li').find('img').attr('src') + '">            <input id="rateinput" type="number" value="1" min="1" max="10">            <label id="ratebutton">rate</label></li>');       }    }); } 

and place in html <ul> lives:

<div id="checkedimagecontainer" class="hidden col-md-4">    <div class="text-center">       <h3>now rate favorite images!!(#1-10)</h3>       <ul class="checkedimagelist"></ul>       <button id="guesscheck">that's opini0n</button>    </div> </div> 

using clearshots suggestion of check against other inputs.

here fiddle, can't have duplicate entries in list of inputs.

https://jsfiddle.net/d9grwkgn/2/

$('input').change(function() {   if ($('input').not(this).map(function() {       return $(this).val();     }).get().indexof($(this).val()) >= 0)     $(this).val(''); }) 

Comments

Popular posts from this blog

c# - ajax - How to receive data both html and json from server? -

swift - Button on Table View Cell connected to local function -