我想我快疯了。尝试验证单选按钮的值,因为 true/false 是在 doPost 之前可以访问的所有内容,我正在使用处理程序 e.parameter 组合。这是工作版本。
奇怪的是,当我添加第六个按钮并尝试验证它时,第六个 e.parameter 返回为未定义。我已经尝试了我能想到的一切。这是非工作版本
我完全迷路了。
这是损坏的代码:
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;
}