Page 1 of 1

Unterminated String Constant

Posted: Thu Dec 05, 2002 10:54 am
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>

Posted: Thu Dec 05, 2002 1:17 pm
by volka
what's the code of OpenCalendar() ?

doesnt even get there

Posted: Thu Dec 05, 2002 2:59 pm
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;

Posted: Thu Dec 05, 2002 7:12 pm
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.

Posted: Fri Dec 06, 2002 2:07 pm
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.

Posted: Fri Dec 06, 2002 2:30 pm
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.

Posted: Fri Dec 06, 2002 2:46 pm
by ebertjb
Changing the field name/id from "#" to "_" didnt help any.

Posted: Fri Dec 06, 2002 3:09 pm
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)

Posted: Fri Dec 06, 2002 3:10 pm
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.

Posted: Wed Jan 08, 2003 11:03 am
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>

Posted: Wed Jan 08, 2003 11:48 am
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.