Tim, Thanks for the reply, and thanks for the great example! I want to direct the user to different forms, the new form has dropdowns and the edit form does not. Is there a way to incorporate the different forms into the cfif statement?
Best regards, Ben -----Original Message----- From: Timothy Heald [mailto:[EMAIL PROTECTED]] Sent: Monday, May 20, 2002 11:28 AM To: CF-Talk Subject: RE: Cfif cfelse question Are you referring to form reuse? You would like to write one form lets say, if it's new it displays something's different than if it is editing an existing record? We normally will key off of 0. If ID gt 0 then you are editing else your not editing. Then at the top of the template you param id to zero. So a basic example would be a single field form like this: <FORM name="myNameForm" action="#self#?fuseaction=name.actionpage" method="post"> Name: <input type="text" name="cName"> </FORM> Now I want this 1 form to be for both editing and adding new names. I can have an edit page with a drop down box where the values are the record (db) id, and the text is the actual name. And I can have one entry, whose value would be 0 that said something like - Add New Record - or some such. Above the form itself you will need to either have a query or a param depending on the id that is sent in. So the whole page may look like this: <CFPARAM name="attributes.id" value="0"> <CFIF attributes.id gt 0> <!--- this is an existing record and you must run the query to get the current value of the cName field ---> <CFQUERY name="getName" datasource="#dsdata#"> Select cName From NameTable Where id = #form.id# </CFQUERY> <!--- dumps this value to attributes scope ---> <CFSET attributes.cName = getName.cName> <!--- set the button value for editing ---> <CFSET buttonValue="Save Changes"> <CFELSE> <!--- make attributes.cName an empty string to input new values ---> <CFSET attributes.cName = ""> <!--- set the button value for adding a new record ---> <CFSET buttonValue = "Add New Record"> </CFIF> <FORM name="myNameForm" action="#self#?fuseaction=name.actionpage" method="post"> Name: <input type="text" name="cName" value="#attributes.cName#"><br /> <input type="submit" value="#buttonValue#"> </FORM> Is that the kind of thing your asking about? Also I am sure there is probably a better way to do this. I know you can get a tag called cf_reuseFormField off of www.fusebox.org. Tim Heald ACP/CCFD :) Application Development www.schoollink.net > -----Original Message----- > From: Andre Turrettini [mailto:[EMAIL PROTECTED]] > Sent: Monday, May 20, 2002 10:58 AM > To: CF-Talk > Subject: RE: Cfif cfelse question > > > I diferentiate by looking at the id. For a new item, its blank or not > defined so isnumeric(id) or isdefined("id") tells you whether your > editing or adding the entry. > > However, I am a bit confused as to your wording "can only get one > portion of the template to show at a time?" Does that mean you want > to show them both? > > DRE > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Monday, May 20, 2002 8:53 AM > To: CF-Talk > Subject: RE: Cfif cfelse question > > > is there any other variables distinguishing between a new and an edit? > if not you should try passing a type variable that does. > > Anthony Petruzzi > Webmaster > 954-321-4703 > [EMAIL PROTECTED] > http://www.sheriff.org > > > -----Original Message----- > From: Ben Covington [mailto:[EMAIL PROTECTED]] > Sent: Monday, May 20, 2002 10:40 AM > To: CF-Talk > Subject: Cfif cfelse question > > > Hello All, > > I'm trying to develop a way to differentiate between a new record or > the editing of a previous entered record using a single template. The > user clicks on the link which passes the variable ID to the template > for the cfif new and cfelse edit - but can only get one portion of the > template to show at a time? I've also tried cfswitch and cfcase to no > avail. > > What else should I try? Any assistance or direction will be greatly > appreciated. > > Best regards, Ben > > > ______________________________________________________________________ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/[email protected]/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

