Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8049391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:46:24+00:00 2026-06-05T06:46:24+00:00

The code below is giving me some headache. It’s a very simple application that

  • 0

The code below is giving me some headache.
It’s a very simple application that has 2 radio buttons and a button. The idea of this app is to record in the spreadsheet the value of the radio button selected.
Now, if I select the 1st radio button(“one”) and then change to the second radio button(“two”) and then back to “one” and click the “Record” button, the app will record 3 times in the spreadsheet. It kind of accumulates the selections.

Don’t know if I made myself clear, but here are the steps to simulate the issue:

1- Run the application below;
2- Select radio button “one”, then “two” and the “one” again and press the “Record” button;
3- Check the spreadsheet for duplicated values.

The more you keep clicking the radio buttons, the more duplicated values will be recorded.

Any idea why this happens and how can I overcome this issue?

function myAppFunction() {
var mydoc = SpreadsheetApp.getActiveSpreadsheet();
var app = UiApp.createApplication().setTitle('Here is the title bar'); 
var panel = app.createVerticalPanel().setId('panel');

//using setName will give you the ability to get the value  
var myRadio1 = app.createRadioButton("group","one").setName('myRadio1').setId('myRadio1');
var myRadio2 = app.createRadioButton("group","two").setName('myRadio2').setId('myRadio2');
var button = app.createButton("Gravar").setId("record_");
//A label will be used to give feedback on the value of the checkBox 
var infoLabel = app.createLabel('Check the box and click submit').setId('infoLabel');

//handlers 
var handler = app.createServerChangeHandler('radio1');
handler.addCallbackElement(panel);  
myRadio1.addClickHandler(handler);

var handler2 = app.createServerChangeHandler('radio2');
handler2.addCallbackElement(panel);  
myRadio2.addClickHandler(handler2);


//put everything in the UI 
panel.add(myRadio1);      
panel.add(myRadio2); 
panel.add(button);
panel.add(infoLabel);

app.add(panel);  
mydoc.show(app);  
}
function radio1(e){
var app = UiApp.getActiveApplication(); 
app.getElementById('myRadio2').setValue(false);
app.getElementById('infoLabel').setText('one is: ' + e.parameter.myRadio1);
var panel = app.getElementById("panel");
var button = app.getElementById("gravar");
var handler = app.createServerClickHandler("record_");
handler.addCallbackElement(panel);
button.addClickHandler(handler);
return app;
}

function radio2(e){
var app = UiApp.getActiveApplication(); 
app.getElementById('myRadio1').setValue(false);
app.getElementById('infoLabel').setText('two is: ' + e.parameter.myRadio2); 
var button = app.getElementById("gravar");
var handler = app.createServerClickHandler("gravar_");
handler.addCallbackElement(app.getElementById("panel"));
button.addClickHandler(handler);

return app;
}
function record_(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Sheet1");
var lastRow = sheet.getLastRow();
var freeCell = sheet.getRange("A1").offset(lastRow, 0);
freeCell.setValue(e.parameter.myRadio1);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:46:25+00:00Added an answer on June 5, 2026 at 6:46 am

    Radio buttons must have the same name to work in normal exclusive OR mode, if you refer to the doc you’ll notice that this is required when using in a standard panel.
    Here is a simple example :

    function radiotest() {
      var app = UiApp.createApplication();
      var panel = app.createVerticalPanel();
      var radioValue = app.createTextBox();
          radioValue.setId("radioValue").setName("radioValue").setVisible(false);
      for(var i = 1; i < 10; i++){
        var name = 'choice '+i;
        var handler = app.createClientHandler().forTargets(radioValue).setText(name);
        panel.add(app.createRadioButton('radio',name).addValueChangeHandler(handler));
      }
      panel.add(radioValue);
      var getit=app.createButton("Valide").setId("val");
      panel.add(getit)                   
      var handler = app.createServerHandler("valide")
      handler.addCallbackElement(panel)
      getit.addClickHandler(handler);
      app.add(panel);
    SpreadsheetApp.getActiveSpreadsheet().show(app);// show app 
    }
    //
    function valide(e){ ;// This function is called when key "validate" is pressed 
      var sh = SpreadsheetApp.getActiveSheet();
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var RadioButton = e.parameter.radioValue;               
      sh.getRange('A1').setValue(RadioButton);
      var app = UiApp.getActiveApplication();
      return app;
    }​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got some code to increase/decrease font size. This is giving me a headache
The code below is giving me the error: column 'id' in field list is
I have been wondering why the code below is giving me different output on
I cannot understand why the code below is giving me this error in firebug
Why is the below code giving a compile time error. Map<String,? extends Object> inputMap
The code below works in FF, Safari, Chrome. But IE is giving me issues.
while trying to reload table the program giving BAD_EXCESS Signal. In below code. -(void)textFieldDidEndEditing:(UITextField
I've simplified my JavaScript code to the example below; this code is giving me
I've got the following java code, which is giving the error below: import java.io.File;
Reward: Has been claimed. Overview: The code giving me the problem is deployed here:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.