473,799 Members | 3,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unterminated string -- within a querystring...?

Hi, this is the first lines of a function. Although it runs, it still
throws an "Unterminat ed string constant" error in the browser. It is
all in one line, just wouldn't fit here.

The error appears to occur right after type='+typeIn+' &id <----before
the =

Any clues appreciated! Thanks, Kathy
function Anomaly(typeIn, idIn,textIn)
{
newWindow = window.open(('A nomaly.aspx?typ e='+typeIn+'&id ='+idIn+'&text= '+textIn),
'Anomaly', 'width=650,heig ht=700,left=100 ,toolbar=no,men ubar=no,resizab le=yes');
Jul 20 '05 #1
5 5718
On 8 Oct 2003 21:32:48 -0700, in comp.lang.javas cript
Ka**********@at tbi.com (KathyB) wrote:
| Hi, this is the first lines of a function. Although it runs, it still
| throws an "Unterminat ed string constant" error in the browser. It is
| all in one line, just wouldn't fit here.
|
| The error appears to occur right after type='+typeIn+' &id <----before
| the =
|
| Any clues appreciated! Thanks, Kathy
|
|
| function Anomaly(typeIn, idIn,textIn)
| {
| newWindow = window.open(('A nomaly.aspx?typ e='+typeIn+'&id ='+idIn+'&text= '+textIn),
| 'Anomaly', 'width=650,heig ht=700,left=100 ,toolbar=no,men ubar=no,resizab le=yes');


You might try breaking the code up-
--------------
function Anomaly(typeIn, idIn,textIn)
{
var URL = "type=" + typeIn + "&id=" + idIn + "&text=" + textIn;

alert ( URL );

newWindow = window.open("An omaly.aspx?" + URL, "Anomaly",
"width=650,heig ht=700,left=100 ,toolbar=no,men ubar=no,resizab le=yes");
}
---------------
Your inputs may have apostrophes which will upset the scheme of
things.
---------------------------------------------------------------
jn****@yourpant sbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------
Jul 20 '05 #2
Thanks. Question, my input will sometimes definitely have apostrophes!
How do I handle that?

Thanks.

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
Kathy Burke <ka**********@a ttbi.com> writes:
Question, my input will sometimes definitely have apostrophes! How
do I handle that?


It shouldn't make a difference.

This is perfectly legal:

var x = 'foo\'bar';
var y = "baz'foo";
var z = 'abc'+x+y+'def' ;

The value of z is the string containing
abcfoo'barbaz'f oodef

Your code looked perfectly legal to me, if used in an HTML setting or
an external Javascript file. If you embed it in XHTML, you must turn
the ampersands into &amp; entities.

My guess would be that you inadvertedly inserted a newline without
noticing. That would give the error message that you got.
Otherwise, I would need to see the function in context in order to
say what is wrong. The code you posted is fine in itself.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4
Lasse, thanks again for your help. I've including my html output in
hopes that you may see something I don't. I also included an apostrophe
in one of my text items...that, too, gives me an error that jscript is
expecing and } or something. I'm using strictly IE 5.5/6. If you could
look at this, I would be ever so grateful! Thanks.

Kathy

<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-16">
<style type="text/css">
bgcolor="#FFFFF F"
h1 {font-family: Gill Sans MT;color: blue;font-size:20pt
font-weight:bold;mar gin-top:0;margin-bottom:0}
h2 {font-family: Gill Sans MT;color: red;font-size:18pt
font-weight:bold;mar gin-top:0;margin-bottom:0}
h3 {font-family: Gill Sans MT;color:
white;font-size:14pt;font-weight:bold;mar gin-top:0;margin-bottom:0}
body {font-family: Gill Sans MT;color: black;font-size:12pt}
p {font-family: Gill Sans MT;color: black;font-size:12pt}
h4 {font-family: Gill Sans MT;color:
white;font-size:12pt;font-weight:bold;tex t-transform:
uppercase;margi n-top:0;margin-bottom:0}
h5 {font-family: Gill Sans MT;color:
white;font-size:12pt;font-weight:bold;mar gin-top:0;margin-bottom:0}
h6 {font-family: Gill Sans MT;color:
black;font-size:12pt;font-weight:bold;mar gin-top:0;margin-bottom:0}
</style>
<title>Work Instruction</title><script language="Javas cript">
function Anomaly(typeIn, idIn,textIn)
{
newWindow = window.open(('A nomaly.aspx?typ e=' + typeIn + '&idNo=' +
idIn + '&text=' + textIn), 'Anomaly',
'width=650,heig ht=700,left=100 ,toolbar=no,men ubar=no,resizab le=yes');
}
function ValidateSave(fo rmRef,fieldName ,min,max) {
var formField = formRef.element s[fieldName];
if (!/^\d+(\.\d+)?$/.test(formField .value)) {
alert('Invalid entry...please try again!');
formField.focus ();
formField.selec t();
return false;
}
if ((formField.val ue < min) || (formField.valu e > max)) {
alert("The entry must be between " +min+ " and " +max+ ".");
formField.focus ();
formField.selec t();
return false;
}
else
{
varScroll = document.body.s crollTop;
document.cookie ="position="+va rScroll;
return confirm("You are about to enter: " +formField.valu e+ " --
click OK to proceed.");
}
}
function ConfirmSave(for mRef,fieldName)
{
var formField = formRef.element s[fieldName];

if ((formField.val ue.length==0) || (formField.valu e==null))
{
alert("You are trying to save a blank entry.");
formField.focus ();
formField.selec t();
return false;
}
else {
varScroll = document.body.s crollTop;
document.cookie ="position="+va rScroll;
return confirm("You are about to enter: " +formField.valu e+ " --
click OK to proceed.");
}
}
function CheckInput()
{
var cnAll = document.all;
for (var i=0;i<cnAll.len gth;i++)

if(cnAll(i).typ e=='text')
{
alert("You must first complete and SAVE all user inputs!");
cnAll(i).focus( );
return false;
}
document.cookie ="position=0 ";
return true;
}
function get_cookie(Name ) {
var search = Name + "="
var returnvalue = "";
if (document.cooki e.length > 0) {
offset = document.cookie .indexOf(search )
// if cookie exists
if (offset != -1) {
offset += search.length
// set index of beginning of value
end = document.cookie .indexOf(";", offset);
// set index of end of cookie value
if (end == -1) end = document.cookie .length;
returnvalue=une scape(document. cookie.substrin g(offset, end))
}
}
return returnvalue;
}
function myScroll()
{
if (get_cookie("po sition")!="") {
varScroll = "";
varScroll = get_cookie("pos ition");
window.scrollTo (0, varScroll);
}
}
</script></head>
<body onload="myScrol l()">
<h1></h1>
<table border="1" width="100%" cellpadding="4" >
<tr bgcolor="red" valign="middle" >
<th colspan="3" align="left">
<h3>SAFETY</h3>
</th>
</tr>
<tr>
<td align="center" valign="middle" width="5%"><inp ut style="CURSOR:
POINTER" type="button" value="Anomaly"
onclick="Javasc ript:Anomaly('S afety','1','Sta tic prevention straps and
lab coats must be worn at all
times.')"></td>
<td valign="top">
<table border="0">
<tr>
<td align="left" valign="top">1. *
</td>
<td valign="top">
<p>Static prevention straps and lab coats must be worn at all
times.</p>
</td>
</tr>
</table>
</td>
</tr>
</table><br><tabl e border="1" width="100%" cellpadding="4" >
<tr bgcolor="orange " valign="middle" >
<th colspan="3" align="left">
<h3>TOOLS AND MATERIALS</h3>
</th>
</tr>
<tr>
<td colspan="2"><b> Tool/Material</b></td>
<td align="center"> <b>Jabil Part No.</b></td>
</tr>
</table><br><tabl e border="1" width="100%" cellpadding="4" >
<tr bgcolor="navy" valign="middle" >
<th align="left" colspan="4">
<h3>PROCESS STEPS</h3>
</th>
<tr onMouseOver="th is.bgColor = '#99FFFF'" onMouseOut="thi s.bgColor =
'#FFFFFF'">
<td align="center" valign="middle" ><input style="CURSOR: POINTER"
type="button" value="Anomaly"
onclick="Javasc ript:Anomaly('S tep','1','Scan all labels from the sheet
before installing on the boards. The total quantity scanned should equal
the total quantity of the work order.')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0" >
<tr>
<td valign="top" width="7">
<table border="0" cellpadding="0" >
<tr>
<td valign="top" width="7">**</td>
<td valign="top">1. **</td>
</tr>
</table>
</td>
<td>
<p>Scan all labels from the sheet before installing on the boards. The
total quantity scanned should equal the total quantity of the work
order.</p>
</td>
</tr>
</table>
</td>
</tr>
<tr onMouseOver="th is.bgColor = '#99FFFF'" onMouseOut="thi s.bgColor =
'#FFFFFF'">
<td align="center" valign="middle" ><input style="CURSOR: POINTER"
type="button" value="Anomaly"
onclick="Javasc ript:Anomaly('S tep','2','Insta ll P/N label and S/N label
as shown in visual aid TEST 10-ME40-865-7446-03-LB01
10-ME40-865-7446-03-LB01.')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0" >
<tr>
<td valign="top" width="7">
<table border="0" cellpadding="0" >
<tr>
<td valign="top" width="7">**</td>
<td valign="top">2. **</td>
</tr>
</table>
</td>
<td>
<p>Install P/N label and S/N label as shown in visual aid TEST <a
target="_blank"
href="\\BOSCIM0 1\CIMBridge\!PR OCESS_ENGINEERI NG\LTX\865-333-03-RAC\LB01.
mdf">10-ME40-865-7446-03-LB01</a><a target="_blank"
href="\\BOSCIM0 1\CIMBridge\!PR OCESS_ENGINEERI NG\LTX\865-7446-03RBC\LB01.
mdf">10-ME40-865-7446-03-LB01</a>.</p>
</td>
</tr>
</table>
</td>
</tr>
<tr onMouseOver="th is.bgColor = '#99FFFF'" onMouseOut="thi s.bgColor =
'#FFFFFF'">
<td align="center" valign="middle" ><input style="CURSOR: POINTER"
type="button" value="Anomaly"
onclick="Javasc ript:Anomaly('S tep','3','Kathy 's Test -- Load the boards
into the loader or into the EKRA E5 Screen Printer manually, as
required.')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0" >
<tr>
<td valign="top" width="7">
<table border="0" cellpadding="0" >
<tr>
<td valign="top" width="7">**</td>
<td valign="top">3. **</td>
</tr>
</table>
</td>
<td>
<p>Kathy's Test -- Load the boards into the loader or into the EKRA E5
Screen Printer manually, as required.</p>
</td>
</tr>
</table>
</td>
</tr>
<tr onMouseOver="th is.bgColor = '#99FFFF'" onMouseOut="thi s.bgColor =
'#FFFFFF'">
<td align="center" valign="middle" ><input style="CURSOR: POINTER"
type="button" value="Anomaly"
onclick="Javasc ript:Anomaly('S tep','4','Opera te the EKRA E5 Screen
Printer, see LINK if needed.')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0" >
<tr>
<td valign="top" width="7">
<table border="0" cellpadding="0" >
<tr>
<td valign="top" width="7">**</td>
<td valign="top">4. **</td>
</tr>
</table>
</td>
<td>
<p>Operate the EKRA E5 Screen Printer, see LINK if needed.</p>
</td>
</tr>
</table>
</td>
</tr>
</tr>
<form name="finish" action="HiddenF inish.aspx?fini sh=yes" method="post"
onsubmit="retur n CheckInput(this );">
<tr bgcolor="red" valign="middle" >
<td align="center" valign="middle" ><input style="CURSOR: POINTER"
type="submit" name="finish" value="FINISH"> </td>
<td align="left">
<font color="white">< b>Click the FINISH button when work instruction is
complete.</b></font>
</td>
</tr>
</form>
</table>
</body>
</html>
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5
Kathy Burke <ka**********@a ttbi.com> writes:
I've including my html output in hopes that you may see something I
don't. I also included an apostrophe in one of my text items...that,
too, gives me an error that jscript is expecing and } or something.
I'm using strictly IE 5.5/6. If you could look at this, I would be
ever so grateful!
Ok, I threw this at IE 6. The error report says unterminated string
constant on line 46. That is this line:
return confirm("You are about to enter: " +formField.valu e+ " --
click OK to proceed.");


Or, more accuratly, these *two* lines.

Maybe your news client have broken the line (which is why you
shouldn't post code with lines longer than about 72 characters, some
newsreaders, including yours, will mangle the code by breaking
lines.).

IE goes on to warn about unterminated string constants on lines:
63, 117, 149, 173, and 221

It also says: Expected ")" on line 198.

Then it starts running and gets "Object expected" on line 107.

I fixed the unterminated string constants by removing the newlines.

The Expected ")" error ended up at line 195, which, sadly, makes no
sense. Line 195 is "</tr>".

Ah. The bug is a few lines further down, at:

onclick="Javasc ript:Anomaly('S tep','3','Kathy 's Test -- Load the boards into the loader or into the EKRA E5 Screen Printer manually, as required.')"></td>

The ' in Kathy's ends the string, and must be escaped:

onclick="Javasc ript:Anomaly('S tep','3','Kathy \'s Test -- Load the boards into the loader or into the EKRA E5 Screen Printer manually, as required.')"></td>

There is no problem having 's in string literals, but you must either
escape them or quote the string literals with "'s instead. In this
case, those would also need to be quoted, since the attribute is
wrapped in double quotes.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
8246
by: Phil Powell | last post by:
if (document.location.href.indexOf('?') >= 0) document.location.href = document.location.href.substring(0, document.location.href.indexOf('?')); if (document.location.href.indexOf('#') >= 0) { document.location.href = document.location.href.substring(0, document.location.href.indexOf('#')) + '?' + newUrl; } else { document.location.href = document.location.href + '?' + newUrl; }
0
2359
by: Christopher M. Lauer | last post by:
I have done my best to answer this question but can not find the proper set of commands. I would like to transform an xml file (in code behind) and display its output in a specific html tag, such as a div with a runat=server. I can somewhat do this if I create a server control and include the control within the html div tag but this method (borrowed from ASP.NET Website Programming by Wrox press thanks guys) does not give me the full...
1
4676
by: vanitha | last post by:
Hi All, I am using "C" to generate the javascript code. And i am getting the following error message "Unterminated string literal" in the mozilla webbrowser for the following syntax. unsigned char *Buf="Test" printf("alert(\"%s\");\n\n",Buf);
9
23714
by: Mark | last post by:
I've run a few simple tests looking at how query string encoding/decoding gets handled in asp.net, and it seems like the situation is even messier than it was in asp... Can't say I think much of the "improvements", but maybe someone here can point me in the right direction... First, it looks like asp.net will automatically read and recognize query strings encoded in utf8 and 16-bit unicode, only the latter is some mutant, non-standard...
2
7214
by: Daniel Secomb | last post by:
Hi, I'm using PostgreSQL 7.3.4 on phpPgAdmin 2.4.2 and I'm getting the following error when I try and run a SQL query on a script: Error - /usr/local/psa/admin/htdocs/domains/databases/phpPgAdmin/db_readdump.php -- Line: 33 PostgreSQL said: ERROR: parser: unterminated quoted string at or near "'Black Tea\015\012Fresh range of leaf tea for drinking black or with
18
7340
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 processing: function saveText( scroll_list, t_area, listToBeUpdated ) { scroll_list.options.text = t_area.text; scroll_list.options.value= t_area.value; var req; var url = "http://mkmxg00/cgi/confirmUpload.pl";
2
16918
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, allso avant browser (shell for IE) dosent see it. the script works fine, i'm just anoyed with IE calling errors. Anybody know why this is?
1
7995
by: larrylyons | last post by:
I don't understand why I'm getting Unterminated String Literal error MY JAVASCRIPT function test(){ newWindow = window.open("","","scrollbars,resizable,height=300,width=200,top=5,left=50",align='center'); newWindow.document.write( "<html><head><title>The Title</title></head>") newWindow.document.write( '<body bgcolor="#ffffcc" onBlur="window.close()"') newWindow.document.write("<BR>This is a test<BR>")
7
25204
by: vunet.us | last post by:
I have a function to open new window: function bla(){ newwin = window.open("page.asp?file=1&id=<%=ID %>","Image","other params") } This function works fine mostly, but sometimes, there is a JavaScript error: "Unterminated string literal". This happens only in one case. If you noticed ASP variable <%=ID%>, then here's what happens to it. ID gets url parameter "id" and inserts in that JavaScript. Obviously, this URL comes from another...
0
9544
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10259
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10238
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5589
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4145
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.