Form Elements?

Results 1 to 3 of 3

Thread: Form Elements?

  1. #1
    Join Date
    Dec 1969

    Default Form Elements?

    I am updating an existing site with an option to delete selected records. The current system generates an html table of information per record in a database. I want to add a checkbox to this table with a caption of "Delete". The user can then go through and select all the records they want to delete. At the bottom of the page a button marked as "Delete selected records" would be provided. The problem I have is how do I get access to the check boxes that are checked, and can I get information from the html table at the same time.<BR><BR>After doing a bit of research I got as far as for each item in Request.Form. I think I can use this to get the check boxes, but can I use it to get the html tables? If I can get the html table can I get the items in the html table. So what I&#039;m thinking of is:<BR>
    <BR>for each tbl in Request.Form<BR>  for each tableItem in tbl<BR>    if tableItem.Name = "Delete" and tableItem.Value = true then <BR>      bDelete = true<BR>    if tableItem.Name = "ID" then sID = tableItem.<BR>  next<BR>  <BR>  if bDelete then DeleteRecord(sID)<BR>next<BR>
    <BR><BR>Just wondering if I&#039;m on the right lines.<BR><BR>Regards,<BR>Marcus

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default Read the FAQs

    You give all the checkboxes the same name and a diff value. The value will be the ID you want to delete<BR><BR>then after the submit you jsut do a simple<BR><BR>"Delete TableName where TheId in (" & Request("CheckboxName") & ")"<BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: Form Elements?

    I would do it this way.<BR><BR>Give all the checkboxes the same name with a value equal to the record id.<BR><BR>&#060;input name="delete" value="31"&#062;<BR>&#060;input name="delete" value="32"&#062;<BR>&#060;input name="delete" value="33"&#062; etc<BR><BR>When the form variable "delete" is posted it will contain a comma delimited string containing all the values of the items that were checked ie:-<BR><BR>Request.form("delete") could equal "31,35,56,57"<BR><BR>if you then split the string into an array you will be able to loop through it retrieving the record id&#039;s that need to be deleted. You should check that the field isn&#039;t empty first or you will generate an error.<BR><BR>deleteArray=split(Request.form("dele te"), ",")<BR>for i=0 to Ubound(deleteArray)<BR> DeleteRecord(deleteArray(CInt(i)))<BR>next<BR><BR> Hope this helps<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts