Page 1 of 2

How do I refer a checkbox generated by mapping an array to checkbox group?

Posted: Thu Jan 23, 2014 11:40 pm
by Fred McIntyre

I added a check box group with one checkbox item.

I am mapping an array to the checkbox item. I need to determine the value of a check box, and if it is checked, with a Click event. In my Javascript, how do I reference the checkbox that was clicked? I tried both $(this)... and Appery(this)... and neither worked.

Thanks


How do I refer a checkbox generated by mapping an array to checkbox group?

Posted: Thu Jan 23, 2014 11:55 pm
by maxkatz

How do I refer a checkbox generated by mapping an array to checkbox group?

Posted: Fri Jan 24, 2014 1:04 am
by Fred McIntyre

Thanks. However, Appery('name') doesn't seem to be working, or I am not understanding.

Here is a screen shot of the builder, showing the javascript. (category_checkboxes is the Checkbox group, obviously). The next shot is the mapping. Then a shot of a test of the service, so you can see that catid does have values. The next shot is the page in the app in a browser, and the last is the alert. I didn't know if I should use the name of the checkbox group or item, so I tried both.

Builder
Image

Mapping
Image

Test
Image

Category list in browser
Image

Alert, showing no values
Image


How do I refer a checkbox generated by mapping an array to checkbox group?

Posted: Fri Jan 24, 2014 10:56 am
by Kateryna Grynko

Hi Fred,

Please post a public link to your app. We would need to take a look.


How do I refer a checkbox generated by mapping an array to checkbox group?

Posted: Mon Jan 27, 2014 6:14 pm
by Fred McIntyre

I sent an email to support, three days ago, with the public link, and the info needed to log into the app. The app has also been shared with support.

I am quite certain that at one time when I chose to run custom javascript on an event, at the top of the edit box, it had "function (value,element)" or something like that - the point being that value and element were sent to the function. I cannot find where I saw that. However, if I could have that sent to the function for the onclick of the check box elements added by mapping an array, that would work well.

I also know that in another place, I was able to use "this.value" to get the value of the element that was clicked on. However, that is not working in this instance.

Somehow, there must be a way to get a reference to the check box that was clicked on. Hopefully, you can help me do that.

Thanks


How do I refer a checkbox generated by mapping an array to checkbox group?

Posted: Mon Jan 27, 2014 6:36 pm
by Kateryna Grynko

Hi Fred,

I'm sorry, I don't see your email. Could you please send it again to a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a? What is your app name?


How do I refer a checkbox generated by mapping an array to checkbox group?

Posted: Mon Jan 27, 2014 6:46 pm
by Fred McIntyre

Sorry, I sent the email as a reply to the email I got from the post here. I see now that went to noreply... (Had to look at Outlook Properties to see the actual email address).

I've forwarded the email to a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a. The name of the app is LW-Fred.

Since the app requires a log in, and there is personal information of other people in it, I didn't want to post all the required info here in the forum.


How do I refer a checkbox generated by mapping an array to checkbox group?

Posted: Mon Jan 27, 2014 7:11 pm
by Kateryna Grynko

Fred,

Thank you, now I can see it. We'll test this.


How do I refer a checkbox generated by mapping an array to checkbox group?

Posted: Mon Jan 27, 2014 8:44 pm
by Fred McIntyre

No answers here, just a report on what I'm finding. I have been doing some experimenting, and have found the this:

I would expect just plain
this.value
to give me the value. It does not. If I have a check box that is not generated by mapping an array to a check box, then it does.

$(this).text() gives me the text shown on the screen for the check box I've clicked. So this is unique for each check box. This makes me think $(this)... should work for other methods, but it doesn't, as the following show

$(this).val() gives a blank. (I added JS to run on output mapping, where the function is: function (value,element) { ...} and doing an alert on value does give each unique value as they are mapped, so I know the values exist)

$(this).attr('name') gives me the name 'category' no matter which check box I click. That is the name of the check box component that the array is mapped to.

$(this).prop('checked') gives me undefined.

$(this).attr('checked') gives me undefined.

$(this).prop('id') gives me undefined.

$(this).attr('id') gives me undefined.

$(this).is(':checked') gives me "false" no matter which check box I click, and no matter if it is checked or not.


How do I refer a checkbox generated by mapping an array to checkbox group?

Posted: Tue Jan 28, 2014 11:15 am
by Maryna Brodina

Hello! So you add event on item, not entire group. If so this will point on item. Try the following way to see if it's checked pre$(this).find("input").is(":checked")/preto get value pre$(this).find("input").val()/pre