0

Help! Function below is working with the dropdown (rubriekskeuze) but not with the textfield (plaatsnaam).

$("#rubriekskeuze,#plaatsnaam").focus(function () {
    //Opslaan huidige waarde
    if (this.id == 'plaatsnaam'){var originele_plaatsnaam = this.value;}else {var originele_rubriek = this.value;}
   }).change(function() {alert('plaa');
        if (this.id == 'rubriekskeuze' && vraag_categorieupdate_gesteld == 0){
            var vraag_update_rub = confirm("Weet u zeker dat u de rubriek wilt wijzigen, bij wijzigen komen de nu ingevulde kenmerken te vervallen en moeten deze opnieuw ingevuld worden voor de nieuwe rubriek");
        }
        if (vraag_categorieupdate_gesteld == 1 || vraag_update_rub){
            alert('dd');
        }
   });
Jilco Tigchelaar
  • 2,065
  • 8
  • 31
  • 51
  • Please generate a jsFiddle so we have some HTML markup to go along with your function. – DevlshOne Aug 22 '13 at 18:56
  • It's also not quite clear what "isn't working" about the function. What is it supposed to do? – Hless Aug 22 '13 at 18:57
  • Or even which of the 2 functions declared isn't working.. – Hless Aug 22 '13 at 18:58
  • ".change" will not fire till you have left the textbox, try and use a `.keyup` for the textbox instead of `.change` if you need to have the function fire everytime a key his used. – Patrick Evans Aug 22 '13 at 18:58
  • if i change the drop down rubriekskeuze the alert 'plaa' executes, if i change the textfield plaatsnaam the alert 'plaa' doesn't execute (after i leave the textfield) – Jilco Tigchelaar Aug 22 '13 at 19:09
  • jsFiddle is a bit dificult because of the size of the page – Jilco Tigchelaar Aug 22 '13 at 19:09
  • Change event fires when you exit textfield. For detecting input see http://stackoverflow.com/questions/1481152/jquery-how-to-detect-a-textboxs-content-has-changed – Tatjana N. Aug 22 '13 at 19:22

1 Answers1

0

Figured it out! It didn't work because of the autocomplete in the textfield...

Jilco Tigchelaar
  • 2,065
  • 8
  • 31
  • 51