Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 10-03-2017, 02:05 AM
noel65 noel65 is offline
Junior Member
 
Join Date: 10-03-17
Posts: 1
iTrader: 0 / 0%
Exclamation disable options in dynamically created selectboxes

Im dynamically creating new dropdown lists for the user in order to input something in a database. I need to disable the previous selections of the user in all the dropdown lists that he creates, (For example, if in the 1st dpl chooses the 1st option then he won't be able to choose it in other dpls.)
Code is ----->here --> jsfiddle.net/npmb1ehf/2/
The code works fine on my pc, I don't know why it doesn't in jsfiddle but you will get an idea of what the code does!

I tried these but no luck... any tips? (also there is an extra thing i tried in the fiddle, it was to long to post it here)

Code:
$('select').on('change', function() { /* enable any previously disabled options */ $('option[disabled]').prop('disabled', false); /* loop over each select */ $('select').each(function() { /* for every other select, disable option which matches this this.value */ $('select').not(this).find('option[value="' + this.value + '"]').prop('disabled', true); }); });

Last edited by J. H. Rasmussen; 10-03-2017 at 02:40 AM. Reason: Added code-wrapper.
 
Reply With Quote

Advertisement

Advertisement

Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 04:38 AM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC