Date:  11/09/2011 03:00:39 PM Msg ID:  004370
From:  FoxWeb Support Thread:  004369
Subject:  Re: Multiple checkbox
Your sample code is not very clear. You need to be more specific about what the various fields represent. I am also not clear on what the hidden field is doing.
One question you need to answer is whether the receiving program needs to know about checkboxes that were left unchecked, in addition to the ones that were checked. If yes, the you do need to use hidden fields; otherwise not.

Here's an example without the hidden fields. I removed some of the HTML to help the important parts stand out:

<%
if !empty(vcname)
 sele welding_joint
 set order to tag name
 set filt to at(upper(vcname),upper(name))>0
 go top
 if !eof()
  scan while !eof()
   %>
   <tr>
    <td width="300" height="13">
     <input type="checkbox" name="selected" value="<%=recno()%>"><%=dwg%>
    </td>        
   </tr>
   <%  
  endscan
 else
  ...

In this case, Request.FormCount("selected") will return the number of checked records. You can loop from 1 to Request.FormCount("selected"), accessing each selected record with Request.Form("selected", i). The return value will be a string representation of recno():

FOR i = 1 TO Request.FormCount("selected")
 recno = INT(VAL(Request.Form("selected", i)))
 ... do whatever you need with recno
NEXT


Here's an example with hidden fields:
<%
if !empty(vcname)
 sele welding_joint
 set order to tag name
 set filt to at(upper(vcname),upper(name))>0
 go top
 if !eof()
  scan while !eof()
   %>
   <tr>
    <td width="300" height="13">
     <input type="checkbox" name="rec<%=recno()%>" value="1"><%=dwg%>
     <input type="hidden" name="record" value="<%=recno()%>">
    </td>        
   </tr>
   <%  
  endscan
 else
  ...

In this case, Request.FormCount("record") will give you the total number of checkboxes. You can cycle through each one, checking for a value of "1", as follows:

FOR i = 1 TO Request.FormCount("record")
 strRecno = Request.Form("record", i)
 recno = INT(VAL(strRecno))
 IF Request.Form(strRecno) = "1"
  ...the field for recno was checked
 ELSE
  ...not checked
 ENDIF
NEXT

Disclaimer: All the code was done off the top of my head and has not been tested or compiled.

FoxWeb Support Team
support@foxweb.com email
Sent by Yoon deokman on 11/09/2011 12:05:52 AM:
Help!
I don't know complete solution to Multi checkbox.
%
 if !empty(vcname)
  sele welding_joint
  set order to tag name
  set filt to at(upper(vcname),upper(name))>0
  go top
  if !eof()
  i=1
  scan while !eof()
     vcname='chk'+allt(str(i))
     vrname='rec'+allt(str(i))
  %>
   <tr style="background-color:white;" onMouseOver=this.style.backgroundColor="eeeeee" onMouseOut=this.style.backgroundColor="white">
   <td width="300" height="13">
   <p align="center"><span style="font-size:9pt;">&nbsp;
   <input type="checkbox" name="<%=vcname%>"><%=dwg%>
   <input type="hidden" name="<%=vrname%>" value="<%=recno()%>"></span></p>
        </td>        
    </tr>
<%  
     i=i+1
endscan
 else
%>

Thanks for any help.