Page 1 of 1

radio button checked from DB query problem

Posted: Wed Feb 26, 2014 9:35 pm
by Bad Addy

Looking at the Appery Docs

http://docs.appery.io/documentation/u...

precode
$('input[name="radio_group"][value="1"]').attr('checked', true);
$('input[name="radio_group"]').checkboxradio("refresh");
/code/pre

But I am unable to get this to work: (my code)

precode
console.log('answer :' + getVar('currentAnswer'));
switch(getVar('currentAnswer')) {
case 1:

Code: Select all

     $('input[name="yesAgreeButton"][value="1"]').attr('checked', true); 

$('input[name="yesAgreeButton"]').checkboxradio("refresh");
break;
case 2:

Code: Select all

 case 3: 

}
/code/pre

Its coming back with 1. Console can see its returning that number. But my button is not selected! The result is either 1,2,3.

Also, I seem to be unable to populate the radio box direct from the query result, if that correct ?

Any ideas ?


radio button checked from DB query problem

Posted: Wed Feb 26, 2014 10:02 pm
by Kateryna Grynko

Hi Addy,

What is this function codegetVar('currentAnswer')/code for?
Or can't you set a value? Then you can use this code:preAppery("yesAgreeButton").find("input").attr('checked',true);
Appery("yesAgreeButton").find("input").refresh();/pre


radio button checked from DB query problem

Posted: Wed Feb 26, 2014 10:27 pm
by Bad Addy

I can use that value currentAnswer. I needed to store the answer from the database, so I put it in localStorage. I then get it out and mark the radio button.

Thank you for the code, i will try it now :)


radio button checked from DB query problem

Posted: Wed Feb 26, 2014 10:42 pm
by Bad Addy

The above code is not working :(


radio button checked from DB query problem

Posted: Wed Feb 26, 2014 11:10 pm
by Bad Addy

Fixed, I will update with correct code tomorrow :)


radio button checked from DB query problem

Posted: Wed Mar 05, 2014 4:49 pm
by steilpass

I have a similar problem. And your code works fine out of the developer console but not from the function call that is invoked by the service mapping.


radio button checked from DB query problem

Posted: Wed Mar 05, 2014 9:23 pm
by Maryna Brodina

Hello @steilpass!

Could you post screenshot to show where did you add code and describe what are you going to do and what exactly doesn't work?


radio button checked from DB query problem

Posted: Thu Mar 06, 2014 12:32 pm
by steilpass

In in the EDIT JS part: Image

BTW: I've got it working by wrapping it in setTimeout

This works:
pre
setTimeout(function(){
element.find("input").prop("checked", true).checkboxradio("refresh");
},0);
/pre
This doesn't:
pre
element.find("input").prop("checked", true).checkboxradio("refresh");
/pre


radio button checked from DB query problem

Posted: Thu Mar 06, 2014 1:54 pm
by Nikita

Hello,

Let's try to change your code to this:

$(element).find("input").attr("checked", false).checkboxradio("refresh");


radio button checked from DB query problem

Posted: Thu Mar 06, 2014 10:41 pm
by steilpass

Grrr. I can't reproduce. Now all versions are working. Sorry.