By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,635 Members | 2,188 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,635 IT Pros & Developers. It's quick & easy.

javascript "Error: Expected ';'"

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.