我想使用网页分阶段收集数据。当用户单击下一步时,我希望从应用程序中删除当前面板并添加一个新面板,但我无法使其正常工作。
这是我当前的代码:
function doGet() {
//Create Application
var app = UiApp.createApplication();
//Set Application Title
app.setTitle("New Lead Form");
/////////////////////////////////Step 1///////////////////////////////////
// Create a Panel for Step 1 Data
var nextbuttonstep1 = app.createButton("Next");
// Create the entry form, a 6 x 2 grid with text boxes for First Name, Last Name, Phone Number, Email, & Property State that is then added to a vertical panel
var grid = app.createGrid(5, 2);
var propertystate = app.createListBox().setName('propertystate').setId('propertystate')
propertystate.addItem('AL');
propertystate.addItem('FL');
propertystate.addItem('IN');
propertystate.addItem('KY');
grid.setWidget(0, 0, app.createLabel('First Name:'));
grid.setWidget(0, 1, app.createTextBox().setName('firstname').setId('firstname'));
grid.setWidget(1, 0, app.createLabel('Last Name:'));
grid.setWidget(1, 1, app.createTextBox().setName('lastname').setId('lastname'));
grid.setWidget(2, 0, app.createLabel('Phone Number:'));
grid.setWidget(2, 1, app.createTextBox().setName('phonenumber').setId('phonenumber'));
grid.setWidget(3, 0, app.createLabel('Email Address:'));
grid.setWidget(3, 1, app.createTextBox().setName('emailaddress').setId('emailaddress'));
grid.setWidget(4, 0, app.createLabel('Property State:'));
grid.setWidget(4, 1, propertystate);
// Create a vertical panel and add the grid to the panel
var step1panel = app.createFlowPanel();
step1panel.add(grid);
step1panel.add(nextbuttonstep1);
app.add(step1panel)
var handler = app.createServerHandler('proceedtostep2');
handler.addCallbackElement(step1panel)
nextbuttonstep1.addClickHandler(handler);
return app;
}
function proceedtostep2(eventInfo) {
var parameter = eventInfo.parameter;
var panel =parameter.step1panel;
var app = UiApp.getActiveApplication();
app.remove(panel);
return app;
}