Unterminated String Constant

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
ebertjb
Forum Newbie
Posts: 12
Joined: Wed Sep 11, 2002 9:46 am

Unterminated String Constant

Post by ebertjb »

I am getting an error "Unterminated String Contant" on this code. The PHP writes out the javascipt, so here is the HTML. This works fine with apache on Linux, but I am using IIS on Win2000.

The error hits after the javascript call - I think because there is a numeric (1) in the string?

when I try to use double quotes, it gives me an illegal character error.

any ideas?

Code: Select all

<INPUT Type="Text" Name="person#1#Birthdate"  SIZE=40 MAXLENGTH=10 VALUE='' >&nbsp;<a name="Cal1" href="javascript:OpenCalendar('person#1#Birthdate');" ><img src="../images/calendar_button.gif" width=21 height=18 border=0 alt="Date Selector"></a>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

what's the code of OpenCalendar() ?
ebertjb
Forum Newbie
Posts: 12
Joined: Wed Sep 11, 2002 9:46 am

doesnt even get there

Post by ebertjb »

It doesnt get to the OpenCalendar function - I put an Alert at the front of this function and it doesnt show, so it isnt even getting there. Here is function though. The function displays an Iframe and loads page Calendar.php inside of it.

Code: Select all

function OpenCalendar(fldName)
&#123;
CloseCalendar();
cal = document.getElementById("CalendarIFrame");

fld = document.getElementById(fldName);
var value = fld.value;

var pos = getXYcoord(fld);

if (fld.offsetWidth)
&#123;
  sizx = fld.offsetWidth;
  sizy = fld.offsetHeight;
&#125;

pos.y = pos.y + sizy;
pos.x = pos.x + sizx;

var calFrame = frames.CalendarIFrame;
if (calFrame)
&#123;
     cal.src = "../calendar.php?dateVal="+value;
&#125;

cal.style.top=pos.y;
cal.style.left=pos.x;
cal.style.display="block";
cal.style.visibility="visible";

&#125;
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

...
fld = document.getElementById(fldName);
...
<INPUT Type="Text" Name="person#1#Birthdate" SIZE=40 MAXLENGTH=10 VALUE='' >
your input-field has only a name not an id by which it shall be selected. Add a id="person#1#Birthdate" to the element.
ebertjb
Forum Newbie
Posts: 12
Joined: Wed Sep 11, 2002 9:46 am

Post by ebertjb »

Is there a similar function GetElementByName? or do I need to add the ID? <just curious>

I will try the ID and repost my findings.
ebertjb
Forum Newbie
Posts: 12
Joined: Wed Sep 11, 2002 9:46 am

Post by ebertjb »

adding the ID didnt work either. Here is my HTML now

Code: Select all

<INPUT Type="Text" ID="person#1#Birthdate" Name="person#1#Birthdate"  SIZE=15 MAXLENGTH=10 VALUE="12-22-1977" >&nbsp;<a name="Cal1" href="javascript:OpenCalendar('person#1#Birthdate');" ><img src="../images/calendar_button.gif" width=21 height=18 border=0 alt="Date Selector"></a>
I wonder what would happen If I used "_" rather than "#" for the name/id.
ebertjb
Forum Newbie
Posts: 12
Joined: Wed Sep 11, 2002 9:46 am

Post by ebertjb »

Changing the field name/id from "#" to "_" didnt help any.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

hmmm...after adding dummy implementations of getXYcoord(), CloseCalendar() and calendar.php it worked on my box.
Maybe you should use an debugger, e.g. the mozilla debugger (http://www.mozilla.org)
Rob the R
Forum Contributor
Posts: 128
Joined: Wed Nov 06, 2002 2:25 pm
Location: Houston

Post by Rob the R »

Your original code (without the PHP call) works for me under Windows NT with IE 5.5. Perhaps the double-single-quote in your VALUE parameter in the "person#1#Birthdate" field should be two double-quotes? Just something else to try.
ebertjb
Forum Newbie
Posts: 12
Joined: Wed Sep 11, 2002 9:46 am

Post by ebertjb »

ok - so I am no longer getting the error, but I cannot access a function in another file - so when I move the function to the top of my page, it works, but I would like to reference this function in another .js file. Is my syntax to reference the js file incorrect?

Code: Select all

<script language="javascript" src="http://localhost/scripts/calendar.js">
</script>
ebertjb
Forum Newbie
Posts: 12
Joined: Wed Sep 11, 2002 9:46 am

Post by ebertjb »

dont really know the answer to this, but when I moved the js file to the root, and set the URL to http://localhost/calendar.js, this works - i double and triple checked the previous path (just one more folder /scripts/) and it doesnt seem to want to navigate into that folder. Oh well - this will do fine.
Post Reply