469,607 Members | 2,205 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,607 developers. It's quick & easy.

javascript "Error: Expected ';'"

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

Sep 22 '05 #1
5 18246
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>

Sep 22 '05 #2
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
theroo wrote:
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>


Sep 22 '05 #3
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.

Sep 22 '05 #4
Lee wrote:
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.


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.

--
Rob
Sep 22 '05 #5
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.

Sep 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Daniel | last post: by
2 posts views Thread by jman | last post: by
reply views Thread by guiromero | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.