Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 1st, 2003, 10:34 AM
Authorized User
 
Join Date: Nov 2003
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default form

I need to create a form that can allow a user to enter multiples of information, and this info update a sinlg e table of a database ie

machine number checked(y/n) date
1 Y 12/12/03
2 N
3 Y 15/12/03

each line being entered as a seperate record into the table of the database. Is this possible and if so, any ideas how i would do this

many thanks

 
Old December 1st, 2003, 10:40 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

This is kind of a vague question.
- What's your experience level? Are you looking for suggestions on the form processing, database interfacing/construction?
- Is the displayed list dynamic? Does it need to handle an unknown number of rows?

Provide a little more detail about this.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old December 1st, 2003, 11:02 AM
Authorized User
 
Join Date: Nov 2003
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ive bene doing asp on and off for 6 months. The form is to populate several rows in a database at once. Using only the one form to enter information about each row in the database. I know how i would create the form, simply have the system loop x amount of times and create the input fields. Im not sure how i would then proces this information to update the database with each indivdual information from the form into its own record

 
Old December 1st, 2003, 11:15 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Ok, now we're talking. So the question is really about a dynamic form.

If you create a row in the form with inputs that are named the same, you'll end up with a comma delimited list of value for each input. Your machine number (which might be a hidden input), the checkboxes and the date field can all by the same input name. The resulting Request("...") values would be something like this:

machine name: 1,2,3
date: 12/12/03,,15/12/03
checked: This poses a problem.

When you have multiple checkboxes with the same name on a form, only the CHECKED ones get posted, so you will have a problem here. Ok, here's a fix...

You create a row for each, there's a hidden form field that holds the machine number. This will essentially create a fixed list of numbers, one for each machine in the table. Then you create the checkbox and data inputs with DIFFERENT names that correspond with the machine number. Here's the resulting HTML I picture:


<input type="hidden" name="machineNum" value="1">
<input type="checkbox" name="checked_1">
<input type="text" name="date_1">

<input type="hidden" name="machineNum" value="2">
<input type="checkbox" name="checked_2">
<input type="text" name="date_2">

The result with will be that Request("machineNum") will look like this again: "1,2,3". You can split that into an array:
aryMachines = Split(Request("machineNum"), ",")

Now, you can just iterate through that array and call the machine specific "checked" and "date" form elements to get the data for each by constructing the request fieldname with the value from the machine name array:

For i = 0 To UBound(aryMachines)
    Request("checked_" & aryMachines(i))
    Request("date_" & aryMachines(i))
Next

Hope this helps.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old December 1st, 2003, 11:35 AM
Authorized User
 
Join Date: Nov 2003
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thankyou for your help, i will give it a try






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to set a form as startup form in vb.net 2.0 mallikalapati .NET Framework 2.0 1 February 21st, 2008 09:19 AM
Close all MdiChield form from open one form/Button salman .NET Framework 2.0 6 December 10th, 2007 03:21 AM
Firefox Error when Form Floated / Form locks socoolbrewster CSS Cascading Style Sheets 5 October 6th, 2007 09:59 PM
How to refresh owner form on closing of child form akumarp2p C# 2005 0 December 22nd, 2006 10:27 AM
parent form from child form - urgent plz netfresher C# 1 November 8th, 2006 06:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.