Herman wrote
I am trying to simply use the return (rfqNumber) from a Javascript script as
a variable in a DTML tag (see code below). I've also tried placing the
Javascript code in-line to the DTML, as well as trying to encapsulating the
script in a DTML method. None of this seems to work. Yes, I am fairly new
to DTML (and Zope, for that matter). I have seen articles on how to pass
arguments from DTML to Javascript functions, but not on how to use
Javascript returns in DTML. Can anyone point, push, or drag me in the right
direction?
Thanks in advance for any help.
Here a sample
<dtml-call "REQUEST.set('user_name',REQUEST.get('AUTHENTICATED_USER').name)">
<html>
<head>
<dtml-var manageT>
<link rel="stylesheet" type="text/css" href="../sabine-r.css">
<title>Filtre 1</title>
</head>
<body>
<dtml-with users><dtml-with "_[user_name]">
<dtml-if "PERIODESseltri == ''">
<P align="center">
<STRONG> Vous devez sélectionner les periodes en premier </STRONG>
</P>
<dtml-else>
<form name="frmFILTER" action="Selectionner_FILTRES" method="post" target="hidden">
<fieldset Style="Padding: 4pt;">
<legend> Filtres disponibles pour l'Etude : </legend>
<table>
<tr>
<dtml-with users><dtml-with "_[user_name]">
<dtml-call "REQUEST.set('contract_id',CONTRACT.CONTRACT_NAME)">
</dtml-with></dtml-with>
<TD></TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<fieldset Style="Padding: 4pt;">
<legend> ------ Filtres disponibles ------ </legend>
<dtml-with users><dtml-with "_[user_name]">
<dtml-if "LIGNESdispo == 0">
<dtml-call "manage_changeProperties(LIGNESdispo=1)">
<dtml-var "methodes.creLignes(sql, contract_id, user_name, REQUEST)">
<dtml-else>
<dtml-var "methodes.getLignes(user_name)">
</dtml-if>
</dtml-with></dtml-with>
</fieldset>
</td>
<TD ALIGN="LEFT" VALIGN="TOP">
<fieldset Style="Padding: 4pt;">
<legend> ----- Filtres sélectionnées ----- </legend>
<select name="FILTRES_SEL" size="15">
<dtml-with users><dtml-with "_[user_name]">
<dtml-if "_.len(FILTRESsel) > 0">
<dtml-in "_.string.split(FILTRESsel,',')">
<dtml-in "_.string.split(_['sequence-item'],':')">
<dtml-if "_['sequence-index']==0">
<OPTION VALUE="<dtml-var sequence-item>">
<dtml-else>
<dtml-var sequence-item>
</dtml-if>
</dtml-in>
</dtml-in>
</dtml-if>
</dtml-with></dtml-with>
</select>
</fieldset>
</td>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="BUTTON" NAME="btnSelFILTRE" onclick="selectFilter()" VALUE="Sélectionner le FILTRE">
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="BUTTON" NAME="btnSupFILTRE" VALUE="Supprimer le FILTRE">
</TD>
</tr></table>
</fieldset>
<input type="hidden" name="txtFILTRESsel" value="">
<input type="hidden" name="txtFILTREind" value="">
<input type="hidden" name="txtFILTRElib" value="">
</form>
<dtml-with users><dtml-with "_[user_name]">
<dtml-if "'FILTRE' in objectIds('Folder')">
<dtml-with FILTRE>
<dtml-in "objectItems()">
<dtml-with id>
<dtml-call "REQUEST.set('filDEB',PERDEBUT)">
<dtml-call "REQUEST.set('filFIN',PERFIN)">
<dtml-call "methodes.filDEBfilFIN(Sabine,REQUEST,users)">
<dtml-var Filter>
</dtml-with>
</dtml-in>
</dtml-with>
</dtml-if>
</dtml-with></dtml-with>
<div id="objFILTER"></div>
<script LANGUAGE="javascript">
function selectFilter()
{
var P1;
var P2;
var Y2;
var x;
var i;
var bon;
var S;
var el;
if (document.all.LIGNES_DISPO.value != null)
{
x = document.all.LIGNES_DISPO.selectedIndex;
P1 = document.all.LIGNES_DISPO.item(x).text;
P2 = document.all.LIGNES_DISPO.item(x).value;
bon = true;
for (i = 0; i < document.all.FILTRES_SEL.length ; i++)
{
document.all.FILTRES_SEL.selectedIndex = i;
Y1 = document.all.FILTRES_SEL.item(i).text;
if (P1 == Y1)
{
bon = false;
}
}
if (bon)
{
el = document.createElement("OPTION");
el.text = P1;
el.value = P2;
document.all.FILTRES_SEL.add(el)
document.all.FILTRES_SEL.selectedIndex = document.all.FILTRES_SEL.length - 1
document.all.LIGNES_DISPO.selectedIndex = document.all.LIGNES_DISPO.selectedIndex + 1
document.all.txtFILTREind.value = P2
document.all.txtFILTRElib.value = P1
}
else
{
alert("Ce Filtre est déjà saisi");
}
}
else
{
alert("Vous devez sélectionner un Filtre");
}
S = "";
for (i = 0; i < document.all.FILTRES_SEL.length; i++)
{
S = S + document.all.FILTRES_SEL.item(i).value + ":" + document.all.FILTRES_SEL.item(i).text;
if (i < document.all.FILTRES_SEL.length - 1)
{
S = S + ",";
}
}
document.all.txtFILTRESsel.value = S;
//alert("submit");
document.all.frmFILTER.submit();
}
</script>
</dtml-if>
</dtml-with></dtml-with>
</body>
</html>
The method Selectionner_FILTRES
<dtml-call "REQUEST.set('user_name',REQUEST.get('AUTHENTICATED_USER').name)">
<dtml-with users><dtml-with "_[user_name]">
<dtml-call "manage_changeProperties(FILTRESsel=txtFILTRESsel)">
<dtml-if "'FILTRE' in objectIds('Folder')">
<dtml-else>
<dtml-call "manage_addFolder(id='FILTRE')">
</dtml-if>
<dtml-with FILTRE>
<dtml-call "REQUEST.set('idFilter',txtFILTREind)">
<dtml-call "manage_addFolder(id=txtFILTREind)">
<dtml-call "_[idFilter].manage_addProperty('VENDANT',' ', 'string')">
<dtml-call "_[idFilter].manage_addProperty('MISEENAVANT',' ', 'string')">
<dtml-call "_[idFilter].manage_addProperty('QUANTITE',' ', 'string')">
<dtml-call "_[idFilter].manage_addProperty('GIRAFE',' ', 'string')">
<dtml-call "_[idFilter].manage_addProperty('XY',' ', 'string')">
<dtml-call "_[idFilter].manage_addProperty('PROSPECTUS',' ', 'string')">
<dtml-call "_[idFilter].manage_addProperty('PERDEBUT',' ', 'string')">
<dtml-call "_[idFilter].manage_addProperty('PERFIN',' ', 'string')">
<dtml-call "_[idFilter].manage_changeProperties(title=txtFILTRElib)">
</dtml-with>
</dtml-with></dtml-with>
<dtml-call "methodes.perDEBperFIN(Sabine,REQUEST,users)">
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Zope">
</HEAD>
<BODY onLoad="frmLoad()">
<Script Language = "javascript">
function frmLoad()
{
s = new String("<dtml-var newFilter>");
parent.right.document.all("objFILTER").insertAdjacentHTML('BeforeBegin', s);
}
</Script>
</BODY>
</HTML>
the method newFilter
<form action='.' name='frm<dtml-var txtFILTREind>' methode='post' target='hidden'><input type='hidden' name='indLIG' value='<dtml-var txtFILTREind>'><fieldset Style='Padding: 4pt;'><legend><dtml-var txtFILTRElib> : </legend><table> <tr><td>Vendant Non Vendant</td> <td> <SELECT name='selVendant' size=1> <OPTION VALUE='0'>Inactif <OPTION VALUE='1'>Oui <OPTION VALUE='2'>Non </SELECT> </td> <td>Mise en Avant</td> <td> <SELECT name='selMiseEnAvant' size=1> <OPTION VALUE='0'>Inactif <OPTION VALUE='1'>Oui <OPTION VALUE='2'>Non </SELECT> </td> </tr> <tr><td>Quantités gratuites</td> <td> <SELECT name='selQteGra' size=1> <OPTION VALUE='0'>Inactif <OPTION VALUE='1'>Oui <OPTION VALUE='2'>Non </SELECT> </td> <td>Girafe</td> <td> <SELECT name='selGirafe' size=1> <OPTION VALUE='0'>Inactif <OPTION VALUE='1'>Oui <OPTION VALUE='2'>Non </SELECT> </td> <TD ALIGN='LEFT' VALIGN='TOP'> <INPUT TYPE='SUBMIT' NAME='Valider_FILTRE:method' VALUE='Valider Filtre'> </TD> </tr> <tr> <td>X pour Y</td> <td> <SELECT name='selXY' size=1> <OPTION VALUE='0'>Inactif <OPTION VALUE='1'>Oui <OPTION VALUE='2'>Non </SELECT> </td> <td>Prospectus</td> <td> <SELECT name='selProspectus' size=1> <OPTION VALUE='0'>Inactif <OPTION VALUE='1'>Oui <OPTION VALUE='2'>Non </SELECT> </td> <TD> <div Id='tgt<dtml-var txtFILTREind>'></div> </TD> </tr> <tr> <td> Période DEBUT</td> <td> <dtml-var selDEB></td> <td>Période FIN</td> <td> <dtml-var selFIN> </td> <TD> </TD> </tr></table></fieldset></form>
the initial frame
<HTML>
<HEAD>
</HEAD>
<frameset cols="0,225,*" frameborder="0">
<frame name="hidden">
<frame name="left" src="<!--#var URL1-->/index-l_html">
<frame name="right" src="<!--#var URL1-->/Description/description_html">
</frameset>
</HTML>
Principe
Each time we select a filter in the listbox the hidden method is called and a new form is inserted with insertAdjacentHTML
in the form without reloading the form. You can as you want newFilter Form.
the informations entered in the newFilter can be validated without reloading the form
'Valider_FILTRE:method' in the newFilter Form
<dtml-call "REQUEST.set('user_name',REQUEST.get('AUTHENTICATED_USER').name)">
<dtml-with users><dtml-with "_[user_name]">
<dtml-with FILTRE>
<dtml-call "REQUEST.set('idFilter',indLIG)">
<dtml-call "_[idFilter].manage_changeProperties(VENDANT=selVendant)">
<dtml-call "_[idFilter].manage_changeProperties(MISEENAVANT=selMiseEnAvant)">
<dtml-call "_[idFilter].manage_changeProperties(QUANTITE=selQteGra)">
<dtml-call "_[idFilter].manage_changeProperties(GIRAFE=selGirafe)">
<dtml-call "_[idFilter].manage_changeProperties(XY=selXY)">
<dtml-call "_[idFilter].manage_changeProperties(PROSPECTUS=selProspectus)">
<dtml-call "_[idFilter].manage_changeProperties(PERDEBUT=selDEBUT)">
<dtml-call "_[idFilter].manage_changeProperties(PERFIN=selFIN)">
</dtml-with>
</dtml-with></dtml-with><HTML>
<HEAD>
<META NAME="GENERATOR" Content="Zope">
</HEAD>
<BODY onLoad="onLoad()">
<Script Language = "javascript">
function onLoad()
{
parent.right.document.all("tgt<dtml-var indLIG>").innerHTML = "(Enregistré)";
}
</Script>
</BODY>
</HTML>
Hope this help
Gerard MULOT
EMail gerard.mulot@noos.fr