Listing Items from Database/Form

8 views
Skip to first unread message

J-vibe

unread,
Apr 13, 2006, 10:51:59 PM4/13/06
to miva-script
Hi,

I'm developing a custom app that requires I list items from a database
to a form. The fields would be something like PartNo, Description,
Price,Qty.
I want them to list in a form (Example:)

HUD-9283 CONNECTOR-A 1.00 [ QTY ]
SDD-5483 CONNECTOR-B 2.00 [ QTY ]
DEE-1313 CONNECTOR-C 5.20 [ QTY ]
etc.....

The qty is to be entered by the user (input type=text). The form will
always have
a random amount of items and can be any part number based on the user
query. I need to be able to identify the part where a qty is entered
and be able
to perform a qty * price for that part.

I know a simple solution would be to have the user click on
a part they want, go to another screen where I can use a generic
<input type="text" name="qty">, But, I'm trying to avoid going to
another screen.

Any suggestions or other method I should consider?

Thanks

Allan James

unread,
Apr 13, 2006, 11:42:58 PM4/13/06
to miva-...@googlegroups.com
Here's one way that doesn't rely on javascript. Just dynamically create
hidden fields for product code and price but make sure they all have the
same name, just different values.
eg..
<input type="hidden" name="prod_code" value="HUD-9283"> CONNECTOR-A
<input type="hidden" name="price" value="1.00"> <input type="text"
name="QTY" value="0">
<input type="hidden" name="prod_code" value="SDD-5483"> CONNECTOR-B
<input type="hidden" name="price" value="2.00"> <input type="text"
name="QTY" value="0">
<input type="hidden" name="prod_code" value="DEE-1313"> CONNECTOR-C
<input type="hidden" name="price" value="5.20"> <input type="text"
name="QTY" value="0">

so when you submit the form you will have three arrays prod_code, price
and qty. Cycle through the arrays using MvWHILE and evaluate only those
lines which have a qty of one or more.

gettoken is an easy way of extracting data from such created arrays

<MvASSIGN NAME="recno" VALUE="1">
<MvWHILE EXPR="{ gettoken(qty,',',recno) }">
<MvEVAL EXPR="{ gettoken(qty,',',recno) * gettoken(price,',',recno) }">
for <MvEVAL EXPR="{ gettoken(prod_code,',',recno) }">
<MvASSIGN NAME="recno" VALUE="{ recno + 1 }">
</MvWHILE>

Hope that helps

Allan

On Fri, 14 Apr 2006 14:51:59 +1200, J-vibe <housemu...@yahoo.com>
wrote:

> __________ NOD32 1.1488 (20060413) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
>
>

--
----------------------------------------
From Allan James
Get Web Design and Hosting
www.getweb.co.nz
Ph 07 889 3337
Mo 0274 86 56 00
----------------------------------------

Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Claudiu Bischoff

unread,
Apr 14, 2006, 6:18:33 AM4/14/06
to miva-...@googlegroups.com
Hi,

Here is an easy way to do it:

http://www.mivascript.org/test/miva_example.mvc

But you should think a little bit AJAX :) There is many ways to do such
things without stressing the server resources and it's quite simple...

If you need more examples just tell me and I'll try to post something in
this way..

Best regards,
Claudiu Bischoff


> -----Message d'origine-----
> De : miva-...@googlegroups.com [mailto:miva-...@googlegroups.com] De
> la part de Allan James
> Envoyé : vendredi 14 avril 2006 05:43
> À : miva-...@googlegroups.com
> Objet : [miva] Re: Listing Items from Database/Form

d'Artagnan

unread,
Apr 14, 2006, 8:58:41 AM4/14/06
to miva-script
-- I updated the code to make it compatible with Mozila too..

best regards,
Claudiu Bischoff

Allan James

unread,
Apr 14, 2006, 9:32:28 AM4/14/06
to miva-...@googlegroups.com
Nice Script Claudiu but it doesn't seem to work with Opera, do you know
why? Not that my IE of FF are on the shelf but I do like Opera so would
be interested to know why something wont work in it.

> __________ NOD32 1.1489 (20060414) Information __________

Claudiu Bischoff

unread,
Apr 14, 2006, 11:04:29 AM4/14/06
to miva-...@googlegroups.com
Hi

Sorry.. I made it quick and I forgot to test it on Opera. I updated it and
now it's working on Opera too

PS: Don't forget to delete your temporary files :)

Best regards,
Claudiu Bischoff

> -----Message d'origine-----
> De : miva-...@googlegroups.com [mailto:miva-...@googlegroups.com] De
> la part de Allan James

> Envoyé : vendredi 14 avril 2006 15:32

J-vibe

unread,
Apr 15, 2006, 12:22:51 PM4/15/06
to miva-script
Thank you for the very fine example. I appreciate your time on this.
One question though, in the input type you used <input name="prod:qnt:
.....
What is the colon between the prod:qnt do?

Claudiu Bischoff

unread,
Apr 15, 2006, 3:55:40 PM4/15/06
to miva-...@googlegroups.com
Hi,

Oh... that's just an old habit I have, using structures (10x 2 Bill :)). You
can use anything instead, but it's simpler to pass dynamic variables like
this. You can use 'prod:prodcode', but if you need to pass more than 1
variable (in our case quantity) I find it more logical to use clear names:
prod:qnt -> talking about quantity, prod:code -> talking about code :)

PS: I'll try to post an example that I use frequently with "pure" AJAX. It's
a little bit different, because we need a framework to make it easy to
program. I'm using Ajax Pages v0.5 and I found it very very easy to
implement (I tried many open-source AJAX frameworks and I found that one
very clean). Here you have a link to see all about it:
http://ajax-pages.sourceforge.net/

Best regards,
Claudiu Bischoff

> -----Message d'origine-----
> De : miva-...@googlegroups.com [mailto:miva-...@googlegroups.com] De

> la part de J-vibe
> Envoyé : samedi 15 avril 2006 18:23
> À : miva-script


> Objet : [miva] Re: Listing Items from Database/Form
>
>

Reply all
Reply to author
Forward
0 new messages