[Zope] <SELECT> in dtml
Oleg Broytmann
Oleg Broytmann <phd@phd.fep.ru>
Fri, 30 Mar 2001 14:05:56 +0400 (MSD)
Hi!
Below is my old (and probably inclomplete) code. Untested. Std
disclaimer :)
On 30 Mar 2001, Gitte Wange wrote:
> I got a lot of replys to my problem but they all just said: Solve it by
> a JavaScript.
> Well ... okay.
> Anyone who has any examples ?
> Because JavaScript is a big world.
>
> Regards,
> Gitte
>
> On 28 Mar 2001 18:42:41 +0200, Gitte Wange wrote:
> > Hello,
> > I am trying to make a site (surprise !)
> > I have a select box and when you choice something in that, a new selectbox should be displayed.
> > Now my problem is that I don't now how the action"script" I have defined in my form-tag recieves the value from the select box.
> >
> > Is there any examples/how-to's anywhere ?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title><!--#var title--></title>
<!--#if "id == -1"-->
<SCRIPT language="JavaScript">
<!--
<!--#in cities-->
array<!--#var sequence-index--> = new Array(<!--#in "regions[_['sequence-item']]"-->
new Array(<!--#if sequence-key--><!--#var sequence-key--><!--#else -->0<!--#/if sequence-key-->, <!--#if sequence-item-->"<!--#var sequence-item-->"<!--#else -->"-----"<!--#/if sequence-item-->)<!--#unless sequence-end-->, <!--#/unless sequence-end-->
<!--#/in -->);
<!--#/in cities-->
function updateMenu2(select) {
array = eval("array" + select.selectedIndex)
region = select.form.region
region_options = region.options
region_options.length = array.length
index_set = 0
for (i = 0; i < array.length; i++) {
region_array = array[i]
region_options[i] = new Option(region_array[1], region_array[0])
if (region_array[0] == <!--#var id_region-->) {
region.selectedIndex = i
index_set = 1
}
}
if (!index_set) {
region.selectedIndex = 0
}
}
// -->
</SCRIPT>
<!--#/if -->
<HEAD>
<body bgcolor="#FFFFFF" text="#000000" leftmargin=0 topmargin=0 marginheight=0 marginwidth=0 link="#003265" vlink="#003265" alink="#003265"
<!--#if "id == -1"-->
onLoad="updateMenu2(document.c2.city)"
<!--#/if -->
>
<!--#if "id == -1"-->
<H3>New</H3>
<!--#else -->
<H3>Edit <!--#var id--></H3>
<!--#/if -->
<FORM name="c2" action="edit-constr.py" method="POST">
<INPUT type="hidden" name="id" value="<!--#var id-->">
<TABLE>
<TR>
<TH>City</TH>
<!--#if "id == -1"-->
<TD>
<SELECT name="city" onChange="updateMenu2(this)">
<!--#in cities-->
<OPTION value="<!--#var sequence-key-->"<!--#if "_['sequence-key'] == id_city"--> selected<!--#/if -->><!--#var sequence-item-->
<!--#/in cities-->
</SELECT>
</TD>
<!--#else -->
<TD><!--#var city--></TD>
<!--#/if -->
</TR>
<TR>
<TH>Region</TH>
<!--#if "id == -1"-->
<TD>
<SELECT name="region">
<OPTION>long junk to preserve space
</SELECT>
</TD>
<!--#else -->
<TD><!--#var region--></TD>
<!--#/if -->
</TR>
<TR>
<TH> </TH>
<TD>
<!--#if "_['sequence-item'][1]"-->
<INPUT type="submit" name="Edit" value="Edit">
<!--#else -->
<INPUT type="submit" name="New" value="New">
<!--#/if -->
</TD>
</TR>
</TABLE>
</FORM>
<!--#/in sides-->
<!--#/if sides-->
</body>
</html>
Oleg.
----
Oleg Broytmann http://www.zope.org/Members/phd/ phd@phd.pp.ru
Programmers don't die, they just GOSUB without RETURN.