access select value with jQuery

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
User avatar
wsiconcrete
Posts: 18
Joined: 2015-04-27 16:39
Location: SC, USA

access select value with jQuery

Post by wsiconcrete » 2020-04-19 08:34

Posting this to jQuery specific forums as well, but thought I would try here since I am not sure if this is specific to the way AG handles the select inputs. At any rate, trying to get a select value and use it in a .each function. If I use the following code I get the correct value and send it to my ajax script.

Code: Select all

$j('#tax_code-container').on('change',function(){
var taxid=$(this).value;
However, when I tried changing this function (below) to catch changes on multiple inputs, I am no longer able to get the value of the select. Console tells me "Cannot read property 'val' of null". I can't understand why it finds the element/value when using $(this) and not when using the direct id of the element. All of the jQuery documentation and examples I can find say this should work.

Code: Select all

$j.each(orderFields, function(index, value) {
	$j(value).on('change',function(){
	var taxid=$('#tax_code-container').val();
Tried taking out the each function and just running alone but get same error, so the each function is not the cause.

Again, I know this may not be specific to AppGini but if anyone has any ideas I will be most grateful! Or you can tell me to go study some more :P

Brandon

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: access select value with jQuery

Post by pbottcher » 2020-04-19 09:23

Hi,

can you change

Code: Select all

var taxid=$('#tax_code-container').val();
to

Code: Select all

var taxid=$j('#tax_code-container').val();
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
wsiconcrete
Posts: 18
Joined: 2015-04-27 16:39
Location: SC, USA

Re: access select value with jQuery

Post by wsiconcrete » 2020-04-19 09:50

well that makes me feel like a fool! I know I tried that but must have been missing something else. That part works now. Thanks for your reply!

Post Reply