Ticket #79 (closed defect: fixed)
javascript needs cleanup in edit_project.tpl.html
| Reported by: | anonymous | Owned by: | florian |
|---|---|---|---|
| Priority: | minor | Milestone: | 0.5 |
| Component: | other | Version: | |
| Keywords: | Cc: |
Description
the template edit_project_tpl.html contains a javascript function which I don't quite understand, but the code looks like it might be broken. Here is the existing code:
function setSelCompany() {
newcpn1 = document.getElementById("newcpn");
field = document.getElementById('s_cpn_id');
newval = field.options[field.selectedIndex].value;
if (newval == -10) {
document.getElementById('new_cpn').value = 1;
newcpn1.style.display = 'block';
document.getElementById("cpn_name").focus();
} else {
document.getElementById('new_cpn').value = 0;
newcpn1.style.display = 'none';
}
}
Looks like you omitted the "_" from the string "newcpn" in the first line of the function. Put that back and it simplifies things:
function setSelCompany() {
newcpn1 = document.getElementById("new_cpn");
field = document.getElementById('s_cpn_id');
newval = field.options[field.selectedIndex].value;
if (newval == -10) {
newcpn1.value = 1;
newcpn1.style.display = 'block';
document.getElementById("cpn_name").focus();
} else {
newcpn1.value = 0;
newcpn1.style.display = 'none';
}
}
I noticed this because the function is called even when it is not defined, in the event that you are editing an existing project. It should be possible to remove the JS at the end when prj_id is equal to 0 as is done in the first JS declaration:
{if ($prjinfo.prj_id == 0)}
{literal}
<script type="text/javascript">
setSelCompany();
document.getElementById("prj_title").focus();
</script>
{/literal}
{/if}
Attachments
Change History
Note: See
TracTickets for help on using
tickets.
