Error Message:
Oops! Your question couldn't be submitted because:
Please add some context to explain the code sections (or check that you have not incorrectly formatted all of your question as code).
How do I fix this issue?
It says that I need to explain my code more when I try to post this as google-apps-script. I have explained almost every part of the code. Also, this code was posted previously and I just added a few extra lines with explanations.
What do they mean by "context"
function doGet() {
var app = UiApp.createApplication();
//Create listBox
var listBox = app.createListBox();
//Add items to listBox
listBox.addItem("item 1").addItem("item 2").addItem("item 3").setName("myListBox");
//Create hidden app
var hidden = app.createHidden().setName('hidden').setId('hidden')
//Create button handler
var handler = app.createServerHandler("buttonHandler");
// pass the listbox into the handler function as a parameter and the hidden widget as well
handler.addCallbackElement(listBox).addCallbackElement(hidden);
//Create flextable
var table = app.createFlexTable().setId("myTable");
//Create flex table style attributes
table.setStyleAttribute("border-style", "solid")
table.setStyleAttribute("border-width", "1px")
table.setCellPadding(1);
//Create flex table headers
table.setWidget(0, 0, app.createLabel("Product Type")).setStyleAttribute("color", "blue");
table.setWidget(0, 5, app.createLabel("Size"));
var button = app.createButton("+", handler);
// add all widgets to the app
app.add(table).add(hidden);
app.add(listBox).add(button)
return app;
}
function buttonHandler(e) {
var app = UiApp.getActiveApplication();
// get the position (is a string)
var pos = e.parameter.hidden;
// initial condition, hidden widget is empty
if(pos==null){pos='0'};
// convert to number
pos=Number(pos);
var table = app.getElementById("myTable");
// add the new item at the right place
table.insertRow(pos).insertCell( pos, 0).setText(pos, 0, e.parameter.myListBox);
// increment position
++pos;
// save value
app.getElementById('hidden').setValue(pos);
// update app
return app;
}
//increment position
<- really? I would have guessed that++pos
increments the position.