Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Need help with how to do a specific part of my form...

Posted on 2006-05-29
13
Medium Priority
?
137 Views
Last Modified: 2010-04-25
I am creating a form in Dreamweaver that I will use to add records to my recipes database. My recipes database has multiple tables, and many one-to-many relationships between tblRecipes and other tables.
I need help with how I set up the form to put in the recipe directions.
I will have one or more "steps", with each step having a number and some text associated with it.
For this, I have a table named tblRecipeSteps that contains the following fields:
StepID (key); RecipeID (relates to tblRecipes); StepNum; StepDetail
So I need a way to input multiple steps on my Recipe form.
I'm experienced with creating repeating regions in Dreamweaver for displaying EXISTING data ... I guess I'm looking for the reverse of this ... how to have repeating regions for input?
Thanks.
0
Comment
Question by:alicia1234
  • 7
  • 6
13 Comments
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 1000 total points
ID: 16786551
Hi alicia,

You can do this one of two ways...

1) If you know (or ask for) the number of regions you will need to enter, you can make a table-based form that has that number of "regions" with the same fields in each region.  The field names would need to be array elements (i.e., input name=text[0] , input name=text[1], etc) and when submitted, the form reads all fields into an array.  You then process the array one group at a time and write each group into the table as a new row.  This is not supported by Dreamweaver, so you will get involved in hand-coding.

2) The easier way is to add the new record to tblRecipes and pull out the primary key value on the next page (form for recipe steps).  Have that form insert the step and loop back to itself for the next one, keeping the tblRecipes primary key as a hidden value the whole time.  Have two submit buttons for the form, one which adds the step and then loops back to the blank form, the other adds the step and goes back to the main page.  This involves checking to see which submit button was hit and also involves a little hand-coding, but not nearly as much as dealing with the array would...
0
 

Author Comment

by:alicia1234
ID: 16786625
OK ... so there is no "magic way" to do it. It involves basically letting the user enter a step and then click a button for "next step" ... until they are done? With each "next step", I would add another field to the form?
0
 

Author Comment

by:alicia1234
ID: 16786786
But when I then process the form ... is there a way to "array" it ... so I know how many steps there were?
And then have code to process an array of steps?
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 16786893
>> It involves basically letting the user enter a step and then click a button for "next step" ... until they are done?

That would be the easiest way considering what you have told me about the set up.  Otherwise you have to ask the user "How many fields will you need?" and return that number of blank fields for steps or just provide some maximum number of blank fields and write a routine that discards the nulls on submit and processes the rest using the array method.  You're better off letting them keep submitting until they select "Submit and Finish" or whatever the second submit button will be called.

>> But when I then process the form ... is there a way to "array" it ... so I know how many steps there were?

If you have the tables set up as a one-to-many, you automatically know this just by selecting from both tables joining on tblRecipes primary key.  The join will return the number of records the user entered.
0
 

Author Comment

by:alicia1234
ID: 16786927
OK .. I'll try it and get back to you.
Thanks.
0
 

Author Comment

by:alicia1234
ID: 16790859
>> 2) The easier way is to add the new record to tblRecipes and pull out the primary key value on the next page (form for recipe steps).  

My primary key for tblRecipes is an autonumber field named RecipeID ... how do I "pull out the primary key value on the next page" (my steps page?)
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 16791098
What server tech are you using?
0
 

Author Comment

by:alicia1234
ID: 16791142
Coldfusion
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 16791476
That is addressed here:

http://www.experts-exchange.com/Web/WebDevSoftware/ColdFusion/Q_21469141.html

Insert the record, then use @@IDENTITY to pull the pk into a value and send it to the next page or use the sort by PK descending and pull the first record trick that is the accepted answer.  @@IDENTITY is a better way to go.
0
 

Author Comment

by:alicia1234
ID: 16791572
Thanks so much. I think I've "got it" now!
In the "Accepted Answer", number 2 is the way I am going to proceed.
Thanks again ... you've helped me before and I really appreciate it. When I publish my website I will let you know. (But I'm sure you'll hear from me again before then!) ;-)
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 16791968
Great!

I cook, so I'll be really interested to see your site live...
0
 

Author Comment

by:alicia1234
ID: 16793069
I will be using MySQL ... I read in the referenced post that @@IDENTITY could be used for SQL Server ... will it also work for MySQL? (Can't find it in my MySQL book!)
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 16793122
Should work...

CF is not my preferred environment, so I don't have a definite answer for you.  The CF TA here will...
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
Loops Section Overview
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question