• Resolved sheohomeliving

    (@sheohomeliving)


    Hi,

    I’d like to disable an option on a select (x[2]) based on value inserted on a number input field (x[1]).

    if (x[1] >= 45) {
    	for (let opt of x[2].options) {
    		(opt.value == 3500).addAttr('disabled', 'disabled');
    	}
    }

    x[1] is a Number input field
    x[2] is a Select input

    Above function doesn’t seem to work

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor DmtLo

    (@lobov)

    Hi.

    Use the field[2] instead x[2].
    Your code must be:

    if (x[1] >= 45) {
    	for (let opt of field[2].options) {
    		if(opt.value == 2) {
    			opt.addAttr('disabled', 'disabled')
    		}
    	}
    }
    Thread Starter sheohomeliving

    (@sheohomeliving)

    That’s solved. Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘AddEventListener: Disable select option based on value inserted’ is closed to new replies.