javascript "Error: Expected ';'"

T

theroo

Hi there,

I am driving myself crazy over this problem.

I have used this very same function in another page without any
problems, but now I am experiencing the "Error: Expected ';'" when i
try and run it, and it doesn't fire (obviously, because there is an
error).

The code is:

function SetDetailValue(i) {
opener.document.<%=Request("tbm")%>.value = i;
window.close();
}

the variable i is passed a string ('d1','d2' etc)

The error occurs (apparently) on the first line.

Please will someone help me with this.

I think maybe I am making a mistake in how I am assigning the variable
into the form value.

Thanks in advance

Andrew
 
T

theroo

Just to say, when the page is compiled (so the <%=Request("tbm")%> is
completed) the script looks like this:

<SCRIPT LANGUAGE="JavaScript">
function Close() {
window.close();
}
function SetDetailValue(i) {
opener.document.frmES.1_sDependant_dCode.value = i;
window.close();
}
</SCRIPT>
 
L

Lee

theroo said:
Just to say, when the page is compiled (so the <%=Request("tbm")%> is
completed) the script looks like this:

<SCRIPT LANGUAGE="JavaScript">
function Close() {
window.close();
}
function SetDetailValue(i) {
opener.document.frmES.1_sDependant_dCode.value = i;
window.close();
}
</SCRIPT>

The problem is the element name that begins with a digit.
That's not allowed. If you change it to any valid character,
the error goes away.
 
B

bakarirum

Looks like the problem isn't Javascript but your JSP/ASP code within
the <%%> tags. First of all is this JSP or ASP. If it is JSP, then
the syntax needs to be request.getParameter("requestvariablename"). I
have not done ASP in a while so I can't remember the syntax for it. I
do remember that there are two different methods on the request object
to get the parameters (one is for query strings (get methods) and the
other is for form data (post methods)).

Bakari
 
R

RobG

Lee said:
theroo said:



The problem is the element name that begins with a digit.
That's not allowed. If you change it to any valid character,
the error goes away.

Presuming that it is a name and not an id, this will work too:

opener.document.frmES.elements['1_sDependant_dCode'].value = i;


If '1_sDependant_dCode' is an id, it will probably still work but it is
not valid HTML - IDs aren't allowed to start with a digit. AFAIK most
browsers will tolerate it anyway.
 
T

theroo

Thank you all.. This has been fixed now and is working fine and super.

I really appreciate the help and the swift response.

Regards

Andrew.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,048
Members
48,769
Latest member
Clifft

Latest Threads

Top