Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

radio button checked from DB query problem

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 ?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

radio button checked from DB query problem

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

Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

radio button checked from DB query problem

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 :)

Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

radio button checked from DB query problem

The above code is not working :(

Bad Addy
Posts: 0
Joined: Fri Dec 13, 2013 9:34 pm

radio button checked from DB query problem

Fixed, I will update with correct code tomorrow :)

steilpass
Posts: 0
Joined: Wed Mar 05, 2014 4:47 pm

radio button checked from DB query problem

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.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

radio button checked from DB query problem

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?

steilpass
Posts: 0
Joined: Wed Mar 05, 2014 4:47 pm

radio button checked from DB query problem

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

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

radio button checked from DB query problem

Hello,

Let's try to change your code to this:

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

steilpass
Posts: 0
Joined: Wed Mar 05, 2014 4:47 pm

radio button checked from DB query problem

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

Return to “Issues”