Wetpants Posted August 3, 2006 Share Posted August 3, 2006 Hello! I've been working on a little contrib which is supposed to switch pictures depending on what the user selected from the pull down menu. Like if a customer is looking at socks and choose 'blue', the picture will change to a pair of blue socks. I think I am almost done, but don't understand the function tep_draw_pull_down_menu well enough. This is my modification for it: $field .= ' onChange = switchimage("'.tep_output_string($name).'",this.options[this.selectedIndex].value)'; But I am only getting numbers with the 2nd arguement to switchimage, not the text value. I'm think the 'for' statement underneath it would help me, but not sure how. So please help me, how do I get the choices the customer selects in the pull down menu as an argument in onchange()? And here is the whole function: // Output a form pull down menu function tep_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) { $field = '<select name="' . tep_output_string($name) . '"'; $field .= ' onChange = switchimage("'.tep_output_string($name).'",this.options[this.selectedIndex].value)'; // ,'.this.selectedIndex.'); // + this.options[this.selectedIndex].value."')'; $field .= '>'; if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]); for ($i=0, $n=sizeof($values); $i<$n; $i++) { $field .= '<option value="' . tep_output_string($values[$i]['id']) . '"'; if ($default == $values[$i]['id']) { $field .= ' SELECTED'; } $field .= '>' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>'; } $field .= '</select>'; if ($required == true) $field .= TEXT_FIELD_REQUIRED; return $field; } Quote Link to comment Share on other sites More sharing options...
Wetpants Posted August 3, 2006 Author Share Posted August 3, 2006 Well, it works anyways, just have to know what number is connected to each choice. Quote Link to comment Share on other sites More sharing options...
Guest Posted August 3, 2006 Share Posted August 3, 2006 have a look how this works. http://www.oscommerce.com/community/contributions,1467 Quote Link to comment Share on other sites More sharing options...
Wetpants Posted August 3, 2006 Author Share Posted August 3, 2006 Uh? Theres a contrib for this? Sheesh, and I been bangin my head... Know of any sites which use this so I can see how it works? Is there a discussion thread? (search func here seems rather limited :/) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.