tlist_sql in drop down
I am trying to use the tlist_sql to build a drop down. It works fine, you can select the value and it is aved, but when you come back to the screen it is not selected. Here is the code:
<td class="bold">Counselor</td> <td><select name="[01]counselor_nkcsd"> <option value=""> ~[tlist_sql; SELECT teachers.lastfirst FROM teachers WHERE teachers.schoolid=~(curschoolid) ORDER BY teachers.lastfirst] <option value="~(teachers.lastfirst;t)">~(teachers.lastfirst;t) [/tlist_sql] </select> </td>
Ideas? IT has to be something simple I am missing. When I look at the rendered code, it looks like a normal select menu, so it seems like it should work???
Comments
Jeff ChristiansenI tried
Jeff Christiansen
I tried the code but now get an empty list. Here is the code-
Counselor
~[f.variable_create;name=t;type=TEXT;when=NEVER]
~[f.variable_set;name=t;value=~([01]counselor_nkcsd)]
~[tlist_sql;
SELECT teachers.lastfirst, CASE WHEN teachers.lastfirst = ~(v.t) THEN 'selected' END AS isselected
FROM teachers
WHERE teachers.schoolid=~(curschoolid)
ORDER BY teachers.lastfirst]
~(teacher;t)
[/tlist_sql]
Try this: ~[tlist_sql; WITH
Try this:
~[tlist_sql;
WITH t_val AS (SELECT '~(v.t)' v_val FROM dual)
SELECT lastfirst, CASE WHEN lastfirst = v_val THEN 'selected' END AS isselected
FROM teachers, t_val
WHERE schoolid=~(curschoolid)
ORDER BY lastfirst]
Jason Treadwell
Custom Solutions Specialist
jason@powerdatasolutions.org
www.powerdatasolutions.org
Jeff Christiansen Now it
Jeff Christiansen
Now it says Non-selected tlist_sql filtered out.
re: Jeff Christiansen Now it
fix-tlistsql-error-5209
Jason Treadwell
Custom Solutions Specialist
jason@powerdatasolutions.org
www.powerdatasolutions.org
re: tlist_sql in drop down
Before your tlist you need to place the value in a variable that the tlist_sql will recognize. I used this method before:
~[f.variable_create;name=t;type=TEXT;when=NEVER]
~[f.variable_set;name=t;value=~([01]counselor_nkcsd)]
Then in the query add a case statement to evaluate
SELECT teachers.lastfirst, CASE WHEN teachers.lastfirst = ~(v.t) THEN 'selected' END isselected FROM ...
Finally, reference the isselected in the option itself
Jason Treadwell
Custom Solutions Specialist
jason@powerdatasolutions.org
www.powerdatasolutions.org