2
votes

I have an ASP Classic application I am trying to debug. There is a loop that iterates through a form's values and it is not returning the correct information. I added in an alert to show me the counter value but it is throwing an error:

Microsoft VBScript runtime error '800a000d'
Type mismatch: '[string: "<script language="ja"]'
/WMD/SA/SA_exp.asp, line 14

Here is the code:

for x = 6 to Request.Form.count()-1
    response.write("<script language=""javascript"">alert ('""" + x + """'); </script>")

If I put any other variable instead of "x" the alert works. How can I get the value of "x" into an alert?

1
The Request.Form.Count is a Property, not a Method. Refactor the line to be For x = 6 To Request.Form.Count - 1. - user692942
alert ('""" + CStr( x) + """'); - JosefZ

1 Answers

0
votes

Response.Write is a sub, not a function. Don't surround the parameter with parens.

I've found that accidentally surrounding parameters with parens works sometimes, but only if the sub is expecting a single numeric parameter. In that case the parens are irrelevant to determining the value of the parameter so it coincidentally works.