0

I'm currently working on a project where we have a DB2 database that contains a string of about 20,000 characters for an email template and the string contains the html we use to build the form.

Currently the old way of the project working is okay but they have requested changes and when I take the string out to make the changes and reinsert it into the table the javascript will no longer function. It will be present there but just doesn't work.

The javascript is very simple, and only creates a list of previous years so hard coding it in is a possibility, but I'd rather not retouch the database every year, and this problem has truly flummoxed me.

Any advice would be greatly appreciated.

Sorry for the edit, first time posting here.

Here is the header:

<head>
<script language="javascript">
<!--    
function buildDateSelect(){ 
    var myDate = new Date();    
    var year = myDate.getFullYear();    
    year--;     
    document.writeln("<option value=\"" + year + "\">" + year); 
    year--;     
    document.writeln("<option value=\"" + year + "\">" + year); 
    year--; 
    document.writeln("<option value=\"" + year + "\">" + year); 
    year--; 
    document.writeln("<option value=\"" + year + "\">" + year); 
    year--; 
    document.writeln("<option value=\"" + year + "\">" + year); 
}   
//-->
</script>

</head>

And here is it being called:

<b>
<fill008>
( <input type="checkbox" name="item008" value="( X ) &nbsp;&nbsp;&nbsp;Year End, indicate years: "/> ) 
&nbsp;&nbsp;&nbsp;Year End, indicate years: 
</fill008>

</b>
<inst>
<span class="date">(Use the CTRL key to select multiple years.)</span>

</inst>
<br/>
<b>

<fill009>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select name="item009" size="5" multiple>
<script language="javascript"><!--    buildDateSelect();//--></script></select>
</fill009>

</b>

My biggest hurdle for this is that it's all legacy code and the people who worked on it before are not in the company any more so I'm flying blind on a lot of it.

Thank you so much.

AngocA
  • 7,655
  • 6
  • 39
  • 55
Paper_Wasp
  • 25
  • 1
  • 8
  • 1
    where is your code? so that we can advise – Hamed Ali Khan Mar 28 '14 at 11:27
  • Edited to add the code in. – Paper_Wasp Mar 28 '14 at 11:53
  • 1) Are you sure the previous version worked? 2) Can you explain how this differs from the previous version? –  Mar 28 '14 at 13:44
  • I know that the previous version worked because I have it saved on other files to be able to check. It breaks when I pull the code off and re-enter it in to the DB2 database. I don't know how it was originally inserted but I assume that has something to do with it. I can copy and paste the string off of the databse and recopy it in and it breaks though. I assume it has something to do with the spacing but not sure what. – Paper_Wasp Mar 28 '14 at 15:09

2 Answers2

0

One possibility: -- is not valid in HTML comments. Thus, the decrement within the Javascript may not work. There is no longer any reason to comment out Javascript code like this. See this answer for more information.

Community
  • 1
  • 1
0

If you are going to wrap the inside of a script element with an HTML comment (why? Do you need to support Netscape 1?), then you must have a new line after it. The rest of the script inside the select element is being treated as part of that comment.

  • Remove the HTML comments
  • Remove the obsolete language attribute
  • Pass your HTML through a validator
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335