Can't process Checkbox in ASP

Here is the problem...

On firstpage.asp I have

<input name="CheckToDelete<%=i%>" type="checkbox" id="CheckToDelete<%=i%>" value="on">
in a loop that dinamicaly changes the checkbox name

On secondpage.asp I have

For i = 1 to NumVar
Redim VarChecked(i) = Request.Form("MyCheckBox" & i & "")

IF VarChecked(i) = "on" THEN
Response.Write("Checked") %><br><%
Else
Response.Write("Unchecked") %><br><%
END IF
NEXT

Why is this code completely non responsive.
What ever I do and no matter how I change the value and into what it simply remains "Unchecked"
deliriumxxAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
>>Redim VarChecked(i) = Request.Form("MyCheckBox" & i & "")
I think the syntax is wrong, and "MyCheckBox" should refer as "CheckToDelete"

Try an example like below:

<%
      NumVar = 10
      Redim VarChecked(NumVar)
      For i = 1 to NumVar
            VarChecked(i) = Request.Form("CheckToDelete" & i & "")
            
            IF VarChecked(i) = "on" THEN
                  Response.Write("Checked") %><br><%
            Else
                  Response.Write("Unchecked") %><br><%
            END IF
      NEXT

%>
<html>
<head>

<title>Untitled Document</title>
</head>

<body>
<form name="form1" method="POST" action="">
  <p>
   <% for i = 1 to 10 %>
    <input type="checkbox" name="CheckToDelete<%=i%>" value="on">
      Checkbox 1<br>
      <% next %>
      </p>
  <p>
    <input name="submit" type="submit" value="Submit">
  </p>
</form>
</body>
</html>
0
deliriumxxAuthor Commented:
No, the syntaks was right....
I changed it here just to explain what I need but I didn't change it all, oooops, sorry.
I am not a newbie in ASP,,, and that is all the more reason I was surprised with this thing. It has been a while since i used it in the extent I am using it now though.

Anyway I solved the problem myself. Yesterday... Now I am deleting multiple records in a few lines of code.
Apparently,,, when i asign the value to the checkbox dinamicaly (in the previous document),,, it is accepted and recognized on the page that does "request.form(key)".
Loop format is realy not an issue here. In the example above I wasn't manipulating the database so it didn't matter (and I wasn't using dymamic database values).
Here it matters.
So this works like a charm..


       i = 0
       Rs.MoveFirst() // here is a record that I need permanently perserved for something
       Rs.MoveNext()
Do While Not RS.EOF
       i = i + 1
       Redim Var(i)
      IF RS("PCode") = Request.Form("CheckBox" & i & "") THEN
            Var(i) = Request.Form("CheckBox" & i & "")
            RS_Manipulate.Execute SQLStatement
      END IF
       Rs.MoveNext()
Loop

Thank you for a good will to try :)
I sometimes post here because I get very fast responses and some great ideas come out of this form of communication.
0
deliriumxxAuthor Commented:
This Line also doesn't serve the purpose of the example

Var(i) = Request.Form("CheckBox" & i & "")

but I am using it in my sql statement so I need it here.
0
moduloCommented:
PAQed with points refunded (50)

modulo
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.