2

I have this situation wherein input fields only appear in the edit form when they are toggled as active in database set-up. Any ideas on how to implement Jquery/AJAX on those fields? For example, i have a dynamic field drop down list. Once a value is selected, another dynamic field drop down list will be populated depending on the first selection.

Here is the scenario:

LastName, FirstName are original form fields

Dynamic Fields are : Address Type.

I can use the Id for LastName & FirstName but How do I use the Id of the Address Type which is only displayed / generated depending on its status in the set-up? and How will I know that the trigger for Address Type is called?

comments are suggested and pardon me for the explanation I can't explain it clearly because I am new to AJAX and JQuery

1 Answer 1

2

You need to associate the events when the fields are created. For example:

$('<input type="text" name"address" id="myAddress" />').keypress(function() {
    //do some things when keypress in address field
}).appendTo('#myForm');
2
  • I generate my form in the PHP code. I can't try your approach. Commented Dec 18, 2014 at 8:22
  • Then simply add the event directly to the element: $('#myAddress').keypress(...). api.jquery.com/category/events for more information
    – Mike Feng
    Commented Dec 19, 2014 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.