PHP form option values

ButtersButters CA Icrontian
edited April 2004 in Internet & Media
I'm trying to set up a shopping cart, (it is actually for a quote system) that is using a PHP array to set the forms. However, I do not want to use a database and I want everything to be PHP based.

The problem is that I want to display values for a particular product. That is, the 'ID' and the 'NAME' of the produt.

Currently I am able to show the ID, because the form uses this value.

I want to be able to have the product NAME show up too.

Here is the link to the testing site


I've tried to create a hidden field that will show the corresponding NAME to the selected ID, but I am unsuccessful.

Is there anyway I could have the 'ID' and corresponding 'NAME' show up in form?

Comments

  • ShortyShorty Manchester, UK Icrontian
    edited April 2004
    The cart you linked has a select tag and..

    [php]
    <option value="2200250">AUREOMYCIN 90 </option>
    [/php]

    Excuse my lack of understanding.. but Im trying to figure out what you are having a problem with.
  • ButtersButters CA Icrontian
    edited April 2004
    When I submit the form, I want it to send both the "ID" which is the '223444' number and the name "AUREOMYCIN 90" to the cart.

    In the cart, it only will show the ID. I want to be able to have the name show up too.

    So far this is what it is displaying.
  • AranyicAranyic Casstown, OH Icrontian
    edited April 2004
    Hmm best way I could see to do it would be setup your form as so:
    [php]<option value="2200250.AUREOMYCIN 90">AUREOMYCIN 90 </option>[/php]

    Then on the cart page have something like:
    [php]
    $product = explode('.',$_POST[product])
    [/php]
    It'll split the value of the form into in array index every time it encounters a period so you'll have:

    id = $product[0]
    name = $product[1]

    Hope that helps a bit.
Sign In or Register to comment.