RadioButton传递值,但第六次失败?

时间:2012-08-30 01:03:37

标签: google-apps-script

我想我会发疯的。尝试验证单选按钮的值,因为true / false是在doPost之前可以访问的所有内容我正在使用处理程序e.parameter组合。这是working version

奇怪的是,只要我添加第六个按钮并尝试验证它,第六个e.parameter就会返回undefined。我已经尝试了所有我能想到的东西。这是non-working version

我完全迷失了。

这是破碎的代码:

function doGet(){
var app = UiApp.createApplication();
var form = app.createFormPanel().setId('form');
var appPanel = app.createVerticalPanel();

var programGrid = app.createGrid(6,5).setWidth('900px');

var programButton1 = app.createRadioButton("program", "Spring 1").setFormValue('Spring 1').setName('program1').setId('program1');
var programButton2 = app.createRadioButton("program", "Spring 2").setFormValue('Spring 2').setName('program2').setId('program2');  
var programButton3 = app.createRadioButton("program", "Spring 3").setFormValue('Spring 3').setName('program3').setId('program3'); 
var programButton4 = app.createRadioButton("program", "Summer 1").setFormValue('Summer 1').setName('program4').setId('program4');
var programButton5 = app.createRadioButton("program", "Summer 2").setFormValue('Summer 2').setName('program5').setId('program5');
var programButton6 = app.createRadioButton("program", "Summer 3").setFormValue('Summer 3').setName('program6').setId('program6');
programGrid.setWidget(0,1, programButton1);
programGrid.setWidget(1,1, programButton2);
programGrid.setWidget(2,1, programButton3);
programGrid.setWidget(0,3, programButton4);
programGrid.setWidget(1,3, programButton5);
programGrid.setWidget(2,3, programButton6);


var button1 = app.createButton("Verify Input").setEnabled(true);
programGrid.setWidget(4,3, button1);

var syncChangeHandler = app.createServerHandler('syncText').addCallbackElement(form);

var reviewPanel = app.createVerticalPanel().setVisible(true).setId('reviewPanel');
var reviewLabel = app.createLabel("REVIEW PANEL")

var reviewProgramLabel = app.createLabel("Program Selected:");
var reviewProgram = app.createLabel().setId('reviewProgram');

var reviewProgramGrid = app.createGrid(2,2);

reviewProgramGrid.setWidget(1,0, reviewProgramLabel);
reviewProgramGrid.setWidget(1,1, reviewProgram);

reviewPanel.add(reviewProgramGrid);

button1.addClickHandler(syncChangeHandler);

app.add(form);
form.add(appPanel);
appPanel.add(programGrid);
appPanel.add(reviewPanel);

return app;
}

function syncText(e){
  var app = UiApp.getActiveApplication(); 
  var a = e.parameter.program1;
  var b = e.parameter.program2;
  var c = e.parameter.program3;
  var d = e.parameter.program4;
  var e = e.parameter.program5;
  var f = e.parameter.program6;

  if(a == "true")
  {
  var g  = "Spring 1";
   }

  if(b == "true")
  {
  var g = "Spring 2";
   }

   if(c == "true")
  {
  var g = "Spring 3";
   }
   if(d == "true")
  {
  var g = "Summer 1";
   }

  if(e == "true")
  {
  var g = "Summer 2";
   }

   if(f == "true")
   {
   var g = "Summer 3";
   }
  app.getElementById('reviewProgram').setText(g);   

return app;
}

1 个答案:

答案 0 :(得分:2)

问题在于:

var e = e.parameter.program5;
var f = e.parameter.program6;

你正在弄乱e,之后问题就出现了。

尝试使用其他变量名称