Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Last bit of code to html_output.php


Wetpants

Recommended Posts

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;
 }

Link to comment
Share on other sites

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...