Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Form Drop Down Menu - BEEF


OSC-Sevilla

Recommended Posts

OK - i want to add a simple drop down menu to my contact form (contact_us.php):

 

-------------

 

<td class="fieldValue"><?php echo tep_draw_drop_menu('entry_reason', isset($_SESSION['customer_entry_reason'])?$_SESSION['customer_entry_reason']:'','class="input"');?>

 

<select name="entry_reason" >

<?php echo '<option value="' . REASONS1 . '">' . REASONS1 . '</option>'; ?>

<?php echo '<option value="' . REASONS2 . '">' . REASONS2 . '</option>'; ?>

<?php echo '<option value="' . REASONS3 . '">' . REASONS3 . '</option>'; ?>

<?php echo '<option value="' . REASONS4 . '">' . REASONS4 . '</option>'; ?>

<?php echo '<option value="' . REASONS5 . '">' . REASONS5 . '</option>'; ?>

<?php echo '<option value="' . REASONS6 . '">' . REASONS6 . '</option>'; ?>

 

</select>

 

 

--------------------

 

STORE THE RESULT:

 

$entry_reason = tep_db_prepare_input($HTTP_POST_VARS['entry_reason']);

 

 

 

--------------------

 

 

I HAVE BEEN PULLING MY HAIR OUT TO GET THIS ONE WORKING.... SO MANY COMBINATIONS AND VARIATIONS HAVE BEEN ATTEMPTED - PLS PLS PLS HELP.

Link to comment
Share on other sites

The parameters for tep_draw_pull_down_menu are ($name, $values, $default = '', $parameters = '', $required = false)

 

$name is the id for the field

$values is the array containing the selection data

$default is the default value selected

$parameters optional styling params

$required adds the defined TEXT_FIELD_REQUIRED text if true

 

 

--------------------

Hardcode the reasons:

<?php echo '<option value="' . REASONS1 . '">' . REASONS1 . '</option>'; ?>

<?php echo '<option value="' . REASONS2 . '">' . REASONS2 . '</option>'; ?>

<?php echo '<option value="' . REASONS3 . '">' . REASONS3 . '</option>'; ?>

<?php echo '<option value="' . REASONS4 . '">' . REASONS4 . '</option>'; ?>

<?php echo '<option value="' . REASONS5 . '">' . REASONS5 . '</option>'; ?>

<?php echo '<option value="' . REASONS6 . '">' . REASONS6 . '</option>'; ?>

 

TO...

 

$select_array[] = array('id' => ' ', 'text' => 'REASONS1');

$select_array[] = array('id' => '0', 'text' => 'REASONS2);

$select_array[] = array('id' => '1', 'text' => 'REASONS3');

$select_array[] = array('id' => '2', 'text' => 'REASONS4');

$select_array[] = array('id' => '3', 'text' => 'REASONS5');

$select_array[] = array('id' => '4', 'text' => 'REASONS6');

 

------------------------------

The html bit:

 

<td align="right" width="100%"><?php echo tep_draw_form('reason', 'get').'Email Subject: ' .

tep_draw_pull_down_menu('select_reason', $reason_array, $selected_reason, 'onchange="this.form.submit();" rel="nofollow"'); ?>

<noscript><input title="View" name="" type="submit" value="Go" /></noscript></form></td>

 

process the data:

 

$selected_reason = ($_GET['select_reason'] > 0 ? $_GET['select_reason'] : false);

 

 

------------------------------------

 

NOT sure if I have this right - some pointers please........

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...