I have a DB table with 3 columns; Month, Term Code, Start Dates. When a user selects one of these from the dbselect menu in the snippet, I need whatever is in the cell below it to also be returned as a variable. Example. A student is taking off the 2305 term of classes, and is scheduled to return in the 2306 term. User selects term 2305 from the menu. Then, the snippet needs to also display "2306" as part of a text string further down on the form. Any thoughts?
You could do something like the following:
{dbselect: SELECT Term FROM Table1 ORDER BY term ASC; space=id; name=terms; multiple=yes}
Terms: {=terms}
Select a term: {formmenu: values={=terms}; itemformatter=(item) -> item.term; name=selected} (the formatting is optional)
Selected item: {=selected}
Selected term: {=selected.term}
Next item: {=terms[location(terms, selected) + 1]}
Thanks Scott! I got this to to work. However, I think its a bit clunky and it requires some modifying of the output so as to only show the actual Term Code instead of the whole row of Data. Maybe I am missing something? For the time being, I think I may stick with just having a 2nd dbselect menu pulling from the same table.
The itemformatter
function on the formmenu in the example above is how you can format the menu entries to only show the term code.
If two dbselects are easier though, definitely go with that approach