473,385 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Unterminated string constant on in IE for complex function

Hello,
I'm attempting to get this code to work in IE.
The script I have below works fine in Firefox but doesn't work in IE.
Basically this script adds an onclick function to radio buttons of a form which is dynamically generated by a java applet.
(I'm not familiar with the java applet nor do I have any control over it.)

Does anyone have any suggestions to make this work in IE?

The error I get is "ERROR: unterminated string constant"
The error is on line 55 which is the line below starting with inputs[i].onclick.
It seems IE does not like the " on this line. If I escape the " IE does not return an error but the data
does not display correctly in the popinframe() function.


Expand|Select|Wrap|Line Numbers
  1.  var texts = new Array();
  2.       function spanify()
  3.       {
  4.                   //addField();                                         
  5.                 var inputs = document.getElementsByTagName('input');
  6.                  for(var i=0; i<inputs.length; i++)
  7.                   {
  8.                         var curnode = inputs[i].nextSibling;
  9.                         var newSpan = document.createElement('span');
  10.                         while(curnode != null)
  11.                         {
  12.                                 if(curnode.tagName != null && curnode.tagName.match(/input/i))
  13.                                 {
  14.                                           curnode = null;
  15.                                 }
  16.                                 else
  17.                                 {
  18.                                           newSpan.appendChild(curnode.cloneNode(true));
  19.                                           curnode = curnode.nextSibling;
  20.                                 }
  21.                         }
  22.                   inputs[i].onclick = new Function("var answers = ('" + megatrim(newSpan.innerHTML.toString()) + "'); popinframe(answers); doSubmit();");      
  23.               }
  24.  
  25.       }
  26.  
  27. function megatrim(str) {
  28.                 str = str.replace(/'/g, "");
  29.                 str = str.replace(/"/g, "");
  30.                 str = str.replace(/^\s+|\s+$|\n/g, '');
  31.                 return str;
  32.         }
Oct 11 '07 #1
2 2493
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

See if this article will help.
Oct 15 '07 #2
pronerd
392 Expert 256MB
The error I get is "ERROR: unterminated string constant"
The error is on line 55 which is the line
I am only seeing lines 1-33. Where is line 55? I noticed on lines 28 and 29 that you have quotes in regular expressions that are not escaped. That is one possible cause of the problem.


Expand|Select|Wrap|Line Numbers
  1.                 str = str.replace(/'/g, "");
  2.                 str = str.replace(/"/g, "");
  3.  
Should be

Expand|Select|Wrap|Line Numbers
  1.                 str = str.replace(/\'/g, "");
  2.                 str = str.replace(/\"/g, "");
  3.  
[/quote]
Oct 16 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: KathyB | last post by:
Hi, this is the first lines of a function. Although it runs, it still throws an "Unterminated string constant" error in the browser. It is all in one line, just wouldn't fit here. The error...
2
by: Tav | last post by:
this seems to be a very generic error message, and the fact that i have no way of locating what causes the error is frustrating. anyway, i'll be general with my problem. i have a div on my page...
18
by: William | last post by:
I have the following javascript function that updates a scroll_list and sends the updated entry (with its index) to a server script ( i.e. http://mkmxg00/cgi/confirmUpload.pl ) for further...
2
by: polilop | last post by:
When i open my page in IE it shows an error Unterminated string constant om Line..... When i look at the line it shows the line where the </SCRIPT> tag is ???? Moziila dose not see this error,...
5
by: ken s | last post by:
From server-side code I'm using Response.Write to display a javascript alert box. It works fine except when I try to include a new line character, which causes this javascript error: ...
2
by: rajuk | last post by:
Hi i have following code,when i execute this code i got unterminated string constant error.any javascript guru can you look into this please. raju /* The link details */ var links = new Array...
1
by: VUNETdotUS | last post by:
Let's say I have a string: div.innerHTML = "<a onclick='foo(\""+myWord+"\");'></a>"; in IE only (tested version 7) if var myWord = "English" then it works fine but if var myWord = "Modifier...
1
by: buntyindia | last post by:
I am getting the following string from the database using Java Text <p>hi m</p> <p>Do Something</p> <p>&nbsp;</p> that I have to load into a javascript based rich text editor.
3
hemantbasva
by: hemantbasva | last post by:
i have written a the following javascript code to copy data onto clipboard but i am getting error Unterminated string constant code in cs file if (lblProcedureID != null) ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.