facebook

If…And….Statements with Radio-Group Buttons

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #336357 Reply

    mreade
    Member

    Support,

    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

    #336422 Reply

    Hi 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.

    #336431 Reply

    mreade
    Member

    Suppoort (Octavio)

    Many thanks, the space has made the difference here.

    Everything seems to be fine now.

    Regards

    mreade

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: If…And….Statements with Radio-Group Buttons

You must be logged in to post in the forum log in