- This topic has 2 replies, 2 voices, and was last updated 11 years, 9 months ago by mreade.
-
AuthorPosts
-
mreadeMemberSupport,
Here is what I am trying to accomplish…..
My app is using a mulipage widget along with a tabBar. The tabBar has four pages, lets call them P1, P2, P3, P4
There is a combobox list called “units” on P4 which has two items: imperial and metric
There is a radio-group1 with two radio buttons called “radio1” and “radio2”. radio1 is set to checked and has a value =1, and radio2 is set to unchecked and has a value = 0.
I’ve added two variables in the frmMain_custom.js file as follows:
var mode = $('select[name="units"] :selected').val(); var Braking = $('input[name="radio-group1"] :checked').val();
My intention is for the following to occur when the mode is set to “imperial” and if not, then to perform the code after “else” when the Braking is not checked, or value = 0:
function calcResults(){ if (mode == "imperial" && Braking == "1") { //Perform this code if "radio1" is checked is true, and mode is set to imperial } else { //Perform this code if "radio2" is checked is true, and mode is set to imperial } }
I can get the calculations to work ok, but it does not matter which radio button I have selected, it always performs the code before the “else” and never after the “else” code. This is the first time I am using radio buttons, so there is obviously something that I am missing here.
I appreciate any assistance one can provide.
Regards
mreade
support-octavioMemberHi mreade,
I’ve evaluate your code and found that the problem is with next line:
var Braking = $(‘input[name=”radio-group1″] :checked’).val();You should remove the space before “:checked”, after that you will get the correct selected value for your radio group and the comparisions should work correctly.
mreadeMemberSuppoort (Octavio)
Many thanks, the space has made the difference here.
Everything seems to be fine now.
Regards
mreade
-
AuthorPosts