Need Dynamic Menu Code
Jim Abrams
jim at publishingresources.com
Fri Jan 4 14:25:06 EST 2002
tlatoure at systemarts.com (Tom) wrote in
news:d7175e2e.0201040815.72296f6d at posting.google.com:
> THANK YOU for your detailed reply. We are using server-side scripting
> with Python on IIS. Would you still recommend the "elaborate CGI for
> dynamic menus in python" code you so kindly provided us, or would you
> recommend something else?
>
> Thanks again for all your help.
If you're forced to use IIS (such as I am), glad to see you went with
Python!
You should be aware of how to jump between pages with information, a simple
form post.
But, if you want a DHTML solution, here's a simple ex.
(Careful of newsreader wrapping)
<%@LANGUAGE="Python"%>
<%
menu1 = ('stooges', 'colors', 'langs')
submenus = {
'stooges': ('moe', 'larry', 'curly'),
'colors': ('blue', 'green', 'red'),
'langs': ('python', 'ruby', 'scheme')
}
%>
<form name=theForm>
<select name=first size=1 onChange='jsfunc()'>
<%
for item in menu1:
Response.Write('<option>%s' % item)
%>
</select>
<br><br>
<select name=second size=1>
<%
for item in submenus['stooges']:
Response.Write('<option>%s' % item)
%>
</select>
</form>
<script language='javascript'>
<!--
function jsfunc() {
<%
# have Python generate DHTML
for i in range(len(menu1)):
Response.Write(" if (document.theForm.first.selectedIndex == %s)
{\n" % i)
subitems = submenus[menu1[i]]
for j in range(len(submenus)):
Response.Write(" document.theForm.second.options[%s].text =
'%s';\n" % (j, subitems[j]))
Response.Write(" }\n")
%>
}
//-->
</script>
===============
More information about the Python-list
mailing list