PDA

View Full Version : PHP form option values


Butters
27 Apr 2004, 6:05am
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 (http://www.cozworth.com/testing/htdocs/tpi.php)


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?

Shorty
27 Apr 2004, 6:21am
The cart you linked has a select tag and..


<option value="2200250">AUREOMYCIN 90 </option>


Excuse my lack of understanding.. but Im trying to figure out what you are having a problem with.

Butters
27 Apr 2004, 2:51pm
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.

Aranyic
27 Apr 2004, 5:10pm
Hmm best way I could see to do it would be setup your form as so:
<option value="2200250.AUREOMYCIN 90">AUREOMYCIN 90 </option>

Then on the cart page have something like:

$product = explode('.',$_POST[product])

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.