ptrau Posted February 19, 2004 Posted February 19, 2004 I am using oscommerce-2.2ms2 Objective I need to add a dropdown field in my "Create Account" main page that holds a value the customer selects for "Community Partnership Program"(cpp). Here is what I have done so far: I created a table named "cpp" with the following fields and test data: CREATE TABLE `cpp` ( `cpp_id` int(11) NOT NULL auto_increment, `cpp_name` varchar(32) NOT NULL default '', `date_added` datetime default NULL, `last_modified` datetime default NULL, PRIMARY KEY (`cpp_id`), KEY `IDX_cpp_NAME` (`cpp_name`) ) TYPE=MyISAM AUTO_INCREMENT=4; # # Dumping data for table `cpp` # INSERT INTO `cpp` VALUES (1, 'St. Peter Chanel Capital Fund', '2004-02-15 22:39:09', '2004-02-15 22:39:09'); INSERT INTO `cpp` VALUES (2, 'Atlanta Food bank', '2004-02-15 22:39:37', '2004-02-15 22:39:37'); INSERT INTO `cpp` VALUES (3, 'test', '2004-02-15 23:08:14', '2004-02-15 23:08:14'); I created a file called "cpp.php" that is called by a require('cpp.php'); in the "create_account.php" file. I used the "includes/boxes/manufacturers.php" file contents as a starting point for the "cpp.php" code by searching and replacing "manufacturers" with "cpp". Here is what the code looks like: <?php /* $Id: cpp.php,v 1.19 2003/06/09 22:17:13 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ $cpp_query = tep_db_query("select cpp_id, cpp_name from " . cpp . " order by cpp_name"); if ($number_of_rows = tep_db_num_rows($cpp_query)) { ?> <!-- cpp //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_cpp); new infoBoxHeading($info_box_contents, false, false); if ($number_of_rows <= MAX_DISPLAY_cpp_IN_A_LIST) { // Display a list $cpp_list = ''; while ($cpp = tep_db_fetch_array($cpp_query)) { $cpp_name = ((strlen($cpp['cpp_name']) > MAX_DISPLAY_CPP_NAME_LEN) ? substr($cpp['cpp_name'], 0, MAX_DISPLAY_CPP_NAME_LEN) . '..' : $cpp['cpp_name']); if (isset($HTTP_GET_VARS['cpp_id']) && ($HTTP_GET_VARS['cpp_id'] == $cpp['cpp_id'])) $cpp_name = '<b>' . $cpp_name .'</b>'; $cpp_list .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cpp_id=' . $cpp['cpp_id']) . '">' . $cpp_name . '</a><br>'; } $cpp_list = substr($cpp_list, 0, -4); $info_box_contents = array(); $info_box_contents[] = array('text' => $cpp_list); } else { // Display a drop-down $cpp_array = array(); if (MAX_cpp_LIST < 2) { $cpp_array[] = array('id' => '', 'text' => PULL_DOWN_DEFAULT); } while ($cpp = tep_db_fetch_array($cpp_query)) { $cpp_name = ((strlen($cpp['cpp_name']) > MAX_DISPLAY_CPP_NAME_LEN) ? substr($cpp['cpp_name'], 0, MAX_DISPLAY_CPP_NAME_LEN) . '..' : $cpp['cpp_name']); $cpp_array[] = array('id' => $cpp['cpp_id'], 'text' => $cpp_name); } $info_box_contents = array(); $info_box_contents[] = array('form' => tep_draw_form('cpp', tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false), 'get'), 'text' => tep_draw_pull_down_menu('cpp_id', $cpp_array, (isset($HTTP_GET_VARS['cpp_id']) ? $HTTP_GET_VARS['cpp_id'] : ''), 'onChange="this.form.submit();" size="' . MAX_cpp_LIST . '" style="width: 100%"') . tep_hide_session_id()); } new infoBox($info_box_contents); ?> </td> </tr> <!-- cpp_eof //--> <?php } ?> Here is what happens: 1) MAJOR Whenever a selection is made from the dropdown box it automatically submits the create account form. When I have tried to remove the code that does this.... onChange="this.form.submit(); for some reason you can no longer submit the "Create Account" form by using the "Continue" button at the bottom of the page. 2) MINOR The dropdown box displays the correct information but is in a box. I have tried to remove the box but each time I break the code. I am not worried that the titles don't show properly because I haven't created a language file for it yet. If anyone has any ideas about these two problems I would really appreciate it. I think I am close but can't figure it out enough to complete it. If I get help to make this work, this would make a good contribution for all the people that need to add fields to their customers info. I will figure out how to display it in their account history later. You can check it out at: gogoGrocery.com Please be gentle as this is a LIVE site. Thanks. "Aliiiiive, it's alive, it's ALIIIIIIIIIIIIIVE!!!"
ptrau Posted February 19, 2004 Author Posted February 19, 2004 bump "Aliiiiive, it's alive, it's ALIIIIIIIIIIIIIVE!!!"
ptrau Posted February 19, 2004 Author Posted February 19, 2004 bump "Aliiiiive, it's alive, it's ALIIIIIIIIIIIIIVE!!!"
Recommended Posts
Archived
This topic is now archived and is closed to further replies.