Using if conditions in JavaScript punch in hidden question like you may want to punch region based on the zip code.
If(pipe zip variable== code) this.question.set(33).
Something like this.
Hey
@Dan,
Hope it helps...
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
var tboxID= "QR~"+this.questionId;
var val = document.getElementById(tboxID).value;
Qualtrics.SurveyEngine.setEmbeddedData("Val",val);
if(val==60606)
{
Qualtrics.SurveyEngine.setEmbeddedData("ZipCode",33);
}
});
@Dan,
Since you have a large number of zip codes you need to map, my preference would be to store them in an external database table, then call a web service to do a lookup and return the associated code as an embedded variable.
To answer your question of how to do it in JavaScript, first define an object with all your zip codes:
```
var zips = {
60606: "33",
etc. (999 more zip codes)
};
```
Then pipe your zip code answer into the script to lookup and set the value of the text input in your hidden question (change QID accordingly):
```
jQuery("#"+this.questionId+" .InputText").val(zips["${q://QID4/ChoiceTextEntryValue}"]);
```