Jump to content

Passing Drop-Down Values between forms


Skor

Recommended Posts

I'm trying to pass a drop down value on a form on one page to a form on the next page and haven't figured it out just yet.  I know I'm missing something, just not sure what.

 

Here's the simple dropdown:

 

<input type="hidden" name="product[]" value="necklace1">
<select name="product[]">
<option value="black cord">black 18 inch rubber cord</option>
<option value="silver chain">18 inch sterling silver box chain</option>
<option value="blue cord-18">blue 18 inch rubber cord</option></select>

 

On the next page, here's the variable:

 

$cord =  ($_POST['product[]']);

 

Further down on the page, here's the select data element:

 

<input type="hidden" name="product[]" value="<?php echo $cord; ?>">

 

I know I'm doing something wrong, after some hefty google trolling, just can't figure out exactly what, but I know I'm not passing the selected value to the next page.  Any ideas?

Link to comment
Share on other sites

The drop-down value is fighting with the actual product value and overwrites the product name.  There is actually a hidden field for the product name:

 

<INPUT TYPE="HIDDEN" NAME="product" VALUE="<?php echo $product; ?>">

 

How do I get it to interact with this line:

<input type="hidden" name="product[]" value="<?php echo $cord[1]; ?>">

 

Actually on the processed Shopping Cart site the information appears this way:

 

product,dropdown value

 

I've tried a few things and gotten the word "Array" to appear not exactly what I'm after either. Or with some tweaking I get "ArrayArray" Do I need to repeat the select form value?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.