Handling User Input With app.response
I am developing a form in which I want a user to interact using a dialog box. The intent is for the user to provide an integer. What is the best way to ensure/enforce that? Here is my code so far:
function updatePg(){
var firstPhN = app.response({cQuestion:"What number should the first photo be?", cTitle:"First Photo Number", cLabel:"Photo:"});
if(parseInt(firstPhN) != "NaN"){
firstPhN = parseInt(firstPhN);
}else{
app.alert("Please input an integer.");
firstPhN = 1;
}
for(var p = 0; p < this.numPages; p++){
if(getFieldOn("pgN", p) != undefined) getFieldOn("pgN", p).value = "Page " + (p + 1) + " of ";
this.getField("pgT").value = this.numPages;
if(getFieldOn("topNum", p) != undefined) getFieldOn("topNum", p).value = "Photo " + ((p*2) + firstPhN) + " - ";
if(getFieldOn("botNum", p) != undefined) getFieldOn("botNum", p).value = "Photo " + ((p + 1)*2 + firstPhN - 1) + " - ";
}
}
Sorry for the readability.. some of my lines are long, and I'm not overly experienced in this space.
When I enter an integer, everyhing works correctly. When I enter letters, the form shows "NaN" in the relevant fields. Why is that? It seems to me that the issue is with my if not going to its else block.
I would like to understand how I can make this approach (using a response box) work. I have made a version where I don't use a rseponse box, and it works fine, although it has its own quirks.
