Akopia Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Re: [mv] Using checkboxes to write multiple values to one field



******    message to minivend-users from Ed LaFrance <edlafrance@printexusa.com>     ******

Bill -

Thanks again for all your help!  I was able to adapt your code and get it 
working in my app.  Doing it on the form page with the Perl in the [set] 
block seemed like the best way, but despite several attempts with changes, 
I repeatedly got internal server errors, so I ended up doing it on the page 
which follows with $Safe->{cgi} and [tag flag write].

I prefer to stick with straight Minivend tags wherever possible...but I am 
really beginning to see why many of the more seasoned Minivend users employ 
a liberal amount of custom Perl in their catalogs.  It seems nearly 
mandatory, if one ever hopes to get the training wheels off :-).

Best Regards,

Ed L.


At 12:37 PM 4/4/00 -0700, you wrote:
>******    message to minivend-users from Bill Randle 
><billr@exgate.tek.com>     ******
>
>Ed,
>
>You don't need a second accept page. I don't know what your real pages look
>like, so it's hard to know exactly what to say. I'm guessing that (a)
>you have a mv_click or mv_check set in your submit form page, or (b) you
>have some stuff embedded in the accept page.
>
>In either case, the solution would be similar. Convert the mutliple checkbox
>values to string. If your values will never have spaces, then you can use
>a space as a delimiter, otherwise you'll need to pick something else
>(e.g. a '|'). Save the new string in a scratch variable then use that
>scratch var instead of the value you were using before in the userdb
>set.
>
>For example:
>
>[set Update Db]
>[perl arg="values scratch"]
>   $myfield = $Safe{values}->{myfield};
>   $myfield =~ s/\0+/|/g;
>   $Safe{scratch}->{myfield} = $myfield;
>[/perl]
>[data table=userdb key='[data session username]' col='somecolumn'
>value='[scratch myfield]']
>[/set]
>
><form action="[process-target" method=POST>
><input type=checkbox name=myfield value="A "> Option A
><input type=checkbox name=myfield value="B "> Option B
><input type=checkbox name=myfield value="C "> Option C
><input type=checkbox name=myfield value="D "> Option D
>
><input type=hidden name=mv_doit value=return>
><input type=hidden name=mv_nextpage value="where-ever-you-go-next">
><input type=hidden name=mv_click value="Update Db">
>
><input type=submit name="mv_click" value="Update Db">
></form>
>
>Note that I used $Safe{values}->{myfield} rather than 'cgi', as we haven't 
>left
>the form yet. cgi may work, I don't know; but I've used values in the past and
>it worked.
>
>         -Bill
>
>
>Ed LaFrance wrote:
> >
> > ******    message to minivend-users from Ed LaFrance 
> <edlafrance@printexusa.com>     ******
> >
> > Ok Bill, I used your code, and as you said, the values are in the form
> > variable.  When checking all three options on the form, your Perl code
> > returned:
> >
> > Checkbox results are: A |B |C
> >
> > I looked at an export of userdb and it appears that B and C never made it
> > into the database - I assume this is due to the null termination you
> > pointed out.
> >
> > I really appreciate your help up to this point!  What would you suggest as
> > a remedy?  I suppose I could pass all the form variables to a secondary
> > acceptance page and remove the null characters there (and the user has to
> > click another submit button), but I suspect you have a better solution...?
> >
> > - Ed L.
> >
> > At 06:35 PM 4/3/00 -0700, you wrote:
> > >******    message to minivend-users from Bill Randle
> > ><billr@exgate.tek.com>     ******
> > >
> > >Ed,
> > >
> > >I think you may have misuderstood my previous message. It's not the fact
> > >that your values have spaces in them, it's the fact that minivend groups
> > >all the checked checkbox values together with a NUL byte ('\0'), which
> > >if you're printing strings, means the end of the string.
> > >
> > >Try adding the code below to your results page (or the page you go to
> > >from your form with the checkboxes):
> > >
> > >     <B>Checkbox results are: </B>[perl arg="cgi"]
> > >         $myfield = $Safe{cgi}->{myfield};
> > >         $myfield =~ s/\0+/|/g;
> > >         return $myfield;
> > >     [/perl]
> > >
> > >Let me know what it shows for various combinations of checked boxes on 
> your
> > >form.
> > >
> > >         -Bill
> > >
> > >Ed LaFrance wrote:
> > > >
> > > > ******    message to minivend-users from Ed LaFrance
> > > <edlafrance@printexusa.com>     ******
> > > >
> > > > Bill -
> > > >
> > > > Would you mind sharing a little of the code from the page where you use
> > > > checkboxes?
> > > >
> > > > I tried removing the trailing spaces from my fields and I am still 
> getting
> > > > only the first checked option in the database.  Note that I have 
> verified
> > > > this by exporting the database and looking at its contents, and by 
> checking
> > > > for values in the field using [if  value] logic.
> > > >
> > > > Also note that if I do this
> > > >
> > > > <input type=checkbox name=myfield value="A B"> Option A B
> > > > <input type=checkbox name=myfield value="C "> Option C
> > > > <input type=checkbox name=myfield value="D "> Option D
> > > >
> > > > Minivend saves and retrieves "A B" repeatedly without problems.  I 
> can also
> > > > change the form element to a text field and type in as many 
> space-separated
> > > > items as I want, and they are saved and retrieved without 
> trouble.  Maybe I
> > > > am misunderstanding this, but I don't think the spaces are the 
> source of my
> > > > trouble.
> > > >
> > > > - Ed L.
>[extra history deleted]
>-
>To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
>email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
>Archive of past messages: http://www.minivend.com/minivend/minivend-list

Printex Marking Technologies
12113 Kirkham Rd.
Poway, CA  92064  U.S.A.
858-513-2418
800-982-1928
858-513-2419 FAX
http://www.printexusa.com

-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: