Re: Updating checkboxes made easy !!!

This WebDNA talk-list message is from

1998


It keeps the original formatting.
numero = 18187
interpreted = N
texte = It's an interesting trick, but I sure wouldn't trust it in any sort of critical application. You are relying on how the browser interprets multiple input fields with the same name, and since this is an HTML no-no (except for groups of radio buttons and groups of checkboxes) you can't be at all confident that any two browsers (or servers for that matter) are going to handle it in the same way. A better way to accomplish the self-updating page is:---update.html----[ShowIf [action]=update] [Replace db=sample.db&eqSKUdatarq=1]Choice1=[HideIf [Choice1]=[Raw][Choice1][/Raw]][Choice1][/HideIf]&Choice2=[HideIf [Choice2]=[Raw][Choice1][/Raw]][Choice2][/HideIf][/Replace] [/ShowIf][Search db=samples.db&eqSKUdatarq=1] [FoundItems]
Choice 1:

Choice 2:

[/FoundItems] [/Search]------------------If you access the page from a normal hypertext link, it will just display your form with whatever data is in the db. When you re-load the page by submiting the form, the hidden variable action triggers the [ShowIf] at the top of the page, your data gets [Replace]d and the form is updated with the new data.-Dave At 3:55 PM 6/11/98, Laurent Pladys wrote: >I have just discovered a way of updating checkbox fields in a database >with only one page ... > >Let say you have the following database : >( choice1 and choice2 are checkboxes in your input form) >------sample.db----- >sku choice1 choice2 >1 on >-------------------- > >If you want to update the content of the checkboxes, usually you have a >first page containing > >Choice 1 : [choice1]=on]checked[/showif]> >

>Choice 2: [choice2]=on]checked[/showif]> > >and in the following page you have to check for the value entered to >update the database with something like that in a replace context > >[showif [choice1]=on]&choice1=on[/showif][showif >[choice1]!on]&choice1=[/showif][showif >>[choice2]=on]&choice2=on[/showif][showif [choice2]!on]&choice2=[/showif] > >Which is not really developper friendly, especially if you want to update >a lot of checkboxes .... > >Now you can update the checkbow from WITHIN the form : > >Choice 1 : [choice1]=on]checked[/showif]> > >

>Choice 2: [choice2]=on]checked[/showif]> > > >Try it for yoursel with the sample database sample.db and the following >page wich auto display itself after you update it (you can edit sample.db >after changing the checkbox to see that it has been updated) > >----- update.tmpl ----- > > > >update checkbox > > >

Update me !

>[search db=update.db&eqskudata=1] >[founditems] >
> > > > > >Choice 1 : [choice1]=on]checked[/showif]> > >

>Choice 2: [choice2]=on]checked[/showif]> > >

> >

>[/founditems] > > >---------- > >Sorry if everybody already knew that but I found this trick very useful. > >Enjoy, > >laurent > >--- >Laurent Pladys >LXir > > L a u r e n t P l a d y s >--------------------------------------------- > L X i r >_____________________________________________ > 1 5 5 r u e d e P i c p u s > 7 5 0 1 2 P a r i s > F r a n c e >_____________________________________________ > +33 (0)1 44 68 80 60 (tel) > +33 (0)1 44 68 80 61 (fax) >_____________________________________________ > w w w . L X i r . n e t > l t p l a d y s @ L X i r . n e t o--------------- Dave MacLeay --+ o----------- Digital Frontier --+ o--- dave@digitalfrontier.com --+ Associated Messages, from the most recent to the oldest:

    
  1. Re: Updating checkboxes made easy !!! (Laurent Pladys 1998)
  2. Re: Updating checkboxes made easy !!! (Dave MacLeay 1998)
  3. Re: Updating checkboxes made easy !!! (Laurent Pladys 1998)
  4. Re: Updating checkboxes made easy !!! (Laurent Pladys 1998)
  5. Updating checkboxes made easy !!! (Laurent Pladys 1998)
  6. Re: Updating checkboxes made easy !!! (Dave MacLeay 1998)
  7. Re: Updating checkboxes made easy !!! (Bob Minor 1998)
It's an interesting trick, but I sure wouldn't trust it in any sort of critical application. You are relying on how the browser interprets multiple input fields with the same name, and since this is an HTML no-no (except for groups of radio buttons and groups of checkboxes) you can't be at all confident that any two browsers (or servers for that matter) are going to handle it in the same way. A better way to accomplish the self-updating page is:---update.html----[ShowIf [action]=update] [Replace db=sample.db&eqSKUdatarq=1]Choice1=[HideIf [Choice1]=[raw][Choice1][/Raw]][Choice1][/HideIf]&Choice2=[HideIf [Choice2]=[raw][Choice1][/Raw]][Choice2][/HideIf][/Replace] [/ShowIf][Search db=samples.db&eqSKUdatarq=1] [founditems]
[thisurl] method=post> Choice 1:

Choice 2:

[/FoundItems] [/Search]------------------If you access the page from a normal hypertext link, it will just display your form with whatever data is in the db. When you re-load the page by submiting the form, the hidden variable action triggers the [showif] at the top of the page, your data gets [replace]d and the form is updated with the new data.-Dave At 3:55 PM 6/11/98, Laurent Pladys wrote: >I have just discovered a way of updating checkbox fields in a database >with only one page ... > >Let say you have the following database : >( choice1 and choice2 are checkboxes in your input form) >------sample.db----- >sku choice1 choice2 >1 on >-------------------- > >If you want to update the content of the checkboxes, usually you have a >first page containing > >Choice 1 : [choice1]=on]checked[/showif]> >

>Choice 2: [choice2]=on]checked[/showif]> > >and in the following page you have to check for the value entered to >update the database with something like that in a replace context > >[showif [choice1]=on]&choice1=on[/showif][showif >[choice1]!on]&choice1=[/showif][showif >>[choice2]=on]&choice2=on[/showif][showif [choice2]!on]&choice2=[/showif] > >Which is not really developper friendly, especially if you want to update >a lot of checkboxes .... > >Now you can update the checkbow from WITHIN the form : > >Choice 1 : [choice1]=on]checked[/showif]> > >

>Choice 2: [choice2]=on]checked[/showif]> > > >Try it for yoursel with the sample database sample.db and the following >page wich auto display itself after you update it (you can edit sample.db >after changing the checkbox to see that it has been updated) > >----- update.tmpl ----- > > > >update checkbox > > >

Update me !

>[search db=update.db&eqskudata=1] >[founditems] >
> > > > > >Choice 1 : [choice1]=on]checked[/showif]> > >

>Choice 2: [choice2]=on]checked[/showif]> > >

> >

>[/founditems] > > >---------- > >Sorry if everybody already knew that but I found this trick very useful. > >Enjoy, > >laurent > >--- >Laurent Pladys >LXir > > L a u r e n t P l a d y s >--------------------------------------------- > L X i r >_____________________________________________ > 1 5 5 r u e d e P i c p u s > 7 5 0 1 2 P a r i s > F r a n c e >_____________________________________________ > +33 (0)1 44 68 80 60 (tel) > +33 (0)1 44 68 80 61 (fax) >_____________________________________________ > w w w . L X i r . n e t > l t p l a d y s @ L X i r . n e t o--------------- Dave MacLeay --+ o----------- Digital Frontier --+ o--- dave@digitalfrontier.com --+ Dave MacLeay

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

Multiple prices, one sku (1999) Feature req. (2002) [math] variable question (1997) carriage returns in data (1997) credit card authorization question (1997) [OT] Merchant Accounts (2007) webcat and OS 8 (1997) Where's 3.0 Online Docs? (1999) Using Cookie for client specific info? (1997) Help getting [shownext] to increment (2003) Replace and Date (2002) MacAuthorize order data fields WAS:How To question... (1997) Deleting Orders (1997) Problem with version 4 browsers (1998) WebCat Documentation (was [platform] tag?) (1998) Running 2 two WebCatalog.acgi's (1996) addlineitems (2003) Feature Request/Rant - Last-modified and Expires MIME (2000) Price characteristics? (1997) TaxRate and ShipCost Problem (1998)