<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        color:black;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        color:black;
        mso-fareast-language:EN-US;}
pre
        {mso-style-priority:99;
        mso-style-link:"Préformaté HTML Car";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;
        mso-fareast-language:FR-CA;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;
        color:black;
        mso-fareast-language:FR-CA;}
span.PrformatHTMLCar
        {mso-style-name:"Préformaté HTML Car";
        mso-style-priority:99;
        mso-style-link:"Préformaté HTML";
        font-family:Consolas;
        color:black;}
span.start-tag
        {mso-style-name:start-tag;}
span.attribute-name
        {mso-style-name:attribute-name;}
span.end-tag
        {mso-style-name:end-tag;}
span.EmailStyle24
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle25
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body bgcolor=white lang=FR-CA link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span style='color:#1F497D'>Hi Christopher,<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-CA style='color:#1F497D'>Thanks for your suggestion. I&#8217;m a bit more familiar to jQuery than Prototype, although I think it would be overkill to load jQuery on top of Prototype just for doing this. I&#8217;m sure there is an easier way to fix this! <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA style='color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-CA style='color:#1F497D'>Could I pass another option to </span><span lang=EN-CA style='font-family:"Courier New"'>render_input_field_actual </span><span lang=EN-CA style='color:#1F497D'>to add the onclick event to the radio button?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA style='color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-CA style='color:#1F497D'>Robin<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-CA style='color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-CA style='color:#1F497D'><o:p>&nbsp;</o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-CA style='color:windowtext;mso-fareast-language:FR-CA'>De&nbsp;:</span></b><span lang=EN-CA style='color:windowtext;mso-fareast-language:FR-CA'> Christopher Gutteridge [mailto:cjg@ecs.soton.ac.uk] <br><b>Envoyé&nbsp;:</b> 1 août 2017 17:</span><span lang=FR style='color:windowtext;mso-fareast-language:FR-CA'>59<br><b>À&nbsp;:</b> eprints-tech@ecs.soton.ac.uk; Robin Sylvestre &lt;robin.sylvestre@polymtl.ca&gt;<br><b>Objet&nbsp;:</b> Re: [EP-tech] Enabling/disabling fields in the workflow using JS<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p>&nbsp;</o:p></p><p>If you need jQuery to make life easier; <span style='font-size:12.0pt;mso-fareast-language:FR-CA'><o:p></o:p></span></p><pre id=line1><o:p>&nbsp;</o:p></pre><pre>  &lt;<span class=start-tag>script</span> <span class=attribute-name>src</span>=&quot;/javascript/jquery.min.js&quot; <span class=attribute-name>type</span>=&quot;text/javascript&quot;&gt;// &lt;!-- No script --&gt;&lt;/<span class=end-tag>script</span>&gt;<o:p></o:p></pre><pre>  &lt;<span class=start-tag>script</span> <span class=attribute-name>type</span>=&quot;text/javascript&quot;&gt;$.noConflict();&lt;/<span class=end-tag>script</span>&gt;<o:p></o:p></pre><pre><o:p>&nbsp;</o:p></pre><p class=MsoNormal style='margin-bottom:12.0pt'>The second bit is vital or it conflicts with prototype.js which also likes to use the $ variable and is required for EPrints features. <o:p></o:p></p><div><p class=MsoNormal>On 01/08/2017 21:51, Robin Sylvestre wrote:<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal>Hello fellow Eprinters!<o:p></o:p></p><p class=MsoNormal>&nbsp;<o:p></o:p></p><p class=MsoNormal><span lang=EN-CA>I&#8217;m trying to enable/disable a date field in the workflow based on the value of a radio button (value = True or False), using JavaScript. Is there an easy way to do it? </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-CA>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-CA><a href="https://wiki.eprints.org/w/Include_Javascript_in_the_workflow">This page</a> contains some clues and I&#8217;ve tried adding a <i>render_input </i>option to my field definition: </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-CA>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span style='font-family:"Courier New"'>{</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>&nbsp; 'name' =&gt; 'diplome_articles',</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>&nbsp; 'type' =&gt; 'boolean',</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>&nbsp; 'multiple' =&gt; 0,</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>&nbsp; 'volatile' =&gt; 0,</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>&nbsp; 'input_style' =&gt; 'radio',</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>&nbsp;&nbsp; 'render_input' =&gt; sub {</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my ( $field, $repository, $current_value, $dataset, $staff, $hidden_fields, $object, $basename ) = @_;</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $dom = $field-&gt;render_input_field_actual( $repository, $current_value, $dataset, $staff, $hidden_fields, $object, $basename );</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>my $script = $repository-&gt;make_javascript('</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>var buttonOpt = document.getElementById(&quot;'.$basename.'&quot;);</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>buttonOpt.addEventListener(&quot;click&quot;, function(){ alert() });</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>');</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp; my $superdom = $repository-&gt;xml-&gt;create_element(&quot;div&quot;);</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $superdom-&gt;appendChild($dom);</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $superdom-&gt;appendChild($script);</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return $superdom;</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt;text-autospace:none'><span lang=EN-CA style='font-family:"Courier New"'>}</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-CA style='font-family:"Courier New"'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-CA>&#8230;but since both radio buttons (true/false) get the same ID when rendered by EPrints, using &#8220;getElementById&#8221; returns only the first element, thus only works when the first option is clicked.</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-CA>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-CA>From the console of my browser, I know I can get the value of the selected option using </span><o:p></o:p></p><p class=MsoNormal><span lang=EN-CA>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-CA style='font-family:"Courier New"'>document.querySelector(&quot;[name$='_diplome_articles']:checked&quot;).value</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-CA>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-CA>&#8230;but I can&#8217;t figure out how to add an event listener for when this value is changing. Actually, the much, much easier way would be to just add </span><span lang=EN-CA style='font-family:"Courier New"'>onclick=&quot;function()&quot; </span><span lang=EN-CA>to the radio button itself and toggle the date field accordingly. But is it possible to do it without hacking EPrints too much? &nbsp;</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-CA>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-CA>Thanks for your help!!</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-CA>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><span lang=EN-CA>&nbsp;</span><o:p></o:p></p><p class=MsoNormal><b><span lang=EN-CA style='font-size:14.0pt;color:#FA961E;mso-fareast-language:FR-CA'>Robin Sylvestre</span></b><o:p></o:p></p><p class=MsoNormal><b><span style='mso-fareast-language:FR-CA'>Technicien en gestion de l&#8217;information numérique</span></b><o:p></o:p></p><p class=MsoNormal><span style='mso-fareast-language:FR-CA'>Services techniques et systèmes informatisés</span><o:p></o:p></p><p class=MsoNormal><span style='mso-fareast-language:FR-CA'>Bibliothèque de l&#8217;École Polytechnique de Montréal</span><o:p></o:p></p><p class=MsoNormal><span style='mso-fareast-language:FR-CA'>514-340-4711 poste 3743</span><o:p></o:p></p><p class=MsoNormal>&nbsp;<o:p></o:p></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:FR-CA'><br><br><br><o:p></o:p></span></p><pre>*** Options: <a href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a><o:p></o:p></pre><pre>*** Archive: <a href="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</a><o:p></o:p></pre><pre>*** EPrints community wiki: <a href="http://wiki.eprints.org/">http://wiki.eprints.org/</a><o:p></o:p></pre><pre>*** EPrints developers Forum: <a href="http://forum.eprints.org/">http://forum.eprints.org/</a><o:p></o:p></pre></blockquote><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:FR-CA'><br><br><o:p></o:p></span></p><pre>-- <o:p></o:p></pre><pre>Christopher Gutteridge -- <a href="http://users.ecs.soton.ac.uk/cjg">http://users.ecs.soton.ac.uk/cjg</a><o:p></o:p></pre><pre><o:p>&nbsp;</o:p></pre><pre>University of Southampton Open Data Service: <a href="http://data.southampton.ac.uk/">http://data.southampton.ac.uk/</a><o:p></o:p></pre><pre>You should read our Web &amp; Data Innovation blog: <a href="http://blogs.ecs.soton.ac.uk/webteam/">http://blogs.ecs.soton.ac.uk/webteam/</a><o:p></o:p></pre><pre><o:p>&nbsp;</o:p></pre></div></body></html>