0

Hi a kind member (ardav) helped me with some php scripting to get a drop list to be populated using an exploded function in php. I need to also add a first option to the list that would say "Choose Color" as the client wants the light and dark colors separated. I need that first option "Choose Color" not to be passed to the cart as they can only choose either a light or dark color. My code so far below:

<?php

// Split the string up into an array of values
$dropdown_data = explode(",", $row_rsApparel['Item_Dark_Colors']);


// Output a dropdown
echo '<select name="DarkColor" id ="DarkColor>';
foreach($dropdown_data as $value) {

  echo '<option value="'.$value.'">'.$value.'</option>';
}
echo '</select>';
?>

any help would truly be appreciated

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by nigelsponge
0
<?php
$dropdown_data = explode(",", $row_rsAppare['Item_Dark_Colors']);
echo '<select name="DarkColor" id ="DarkColor>';
echo '<option selected="selected" value="">Choose Color</option>';
foreach($dropdown_data as $value) { 
echo '<option value="'.$value.'">'.$value.'</option>'; 
}
echo '</select>';
?>

Edited by almostbob: n/a

0

Thanks so much, I had tried what you wrote but i put the

echo '<option selected="selected" value="">Choose Color</option>';

inside the

foreach() loop.

thanks again

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.