Forum Moderators: open
<form name="new_pro" method="post" onsubmit="return validate_form(this)" method="post" enctype="multipart/form-data">
<select name="supplier[3]">
<option value="" selected="selected">--none--</option><option value="23">23</option>
<option value="24">24</option></select>
<select name="supplier[4]">
<option value="" selected="selected">--none--</option><option value="23">23</option>
<option value="24">24</option></select> <script type="text/javascript">
function changeindex(thisselect){
var dropdown = document.getElementsByTagName('select');
for(var i = 0; i < dropdown.length; i++){
if(dropdown[i].name != thisselect.name){
for(var j = 0; j < dropdown[i].options.length; j++){
if(dropdown[i].options[j].value == thisselect.options[thisselect.selectedIndex].value){
dropdown[i].options[j].selected = true;
}
}
}
}
}
</script>
<form name="new_pro" method="post" onsubmit="return validate_form(this)"
method="post" enctype="multipart/form-data">
<select name="supplier[1]" onchange="changeindex(this);">
<option value="" selected="selected">--none--</option>
<option value="23">23</option>
<option value="24">24</option>
</select>
<select name="supplier[2]" onchange="changeindex(this);">
<option value="" selected="selected">--none--</option>
<option value="23">23</option>
<option value="24">24</option>
</select>
<select name="supplier[3]" onchange="changeindex(this);">
<option value="" selected="selected">--none--</option>
<option value="23">23</option>
<option value="24">24</option>
</select>
<select name="supplier[4]" onchange="changeindex(this);">
<option value="" selected="selected">--none--</option>
<option value="23">23</option>
<option value="24">24</option>
</select>
</form>
<script type="text/javascript">
var supplier = new function(){
self = this;
self.select = {
'dropdown': [],
'which': '',
'mode': false,
'load': function(){
this.dropdown = document.getElementsByTagName('select');
this.reset();
this.mode = false;
},
'change': function(select){
this.which = select.options[select.selectedIndex];
if(select.name == 'mode'){
this.mode = (this.which.value == 'manual') ? false : true;
}
if(!this.mode){return}
this.changeindex();
},
'changeindex': function(){
for(var i = 0; i < this.dropdown.length; i++){
if(this.dropdown[i].name == 'mode'){
i++;
}
if(this.dropdown[i].name != this.which.name){
for(var j = 0; j < this.dropdown[i].options.length; j++){
if(this.dropdown[i].options[j].value == this.which.value){
this.dropdown[i].options[j].selected = true;
}
}
}
}
},
'reset': function(){
for(var i = 0; i < this.dropdown.length; i++){
this.dropdown[i].options[0].selected = true;
}
}
};
};
window.onload = function(){
supplier.select.load();
}
</script>
<form name="new_pro" method="post" onsubmit="return validate_form(this)"
method="post" enctype="multipart/form-data">
<select name="mode" onchange="supplier.select.change(this);">
<option value="manual">Manual Mode</option>
<option value="automatic">Automatic Mode</option>
</select>
<select name="supplier[1]" onchange="supplier.select.change(this);">
<option value="" selected="selected">--none--</option>
<option value="23">Combat Robot</option>
<option value="24">Servant Robot</option>
</select>
<select name="supplier[2]" onchange="supplier.select.change(this);">
<option value="" selected="selected">--none--</option>
<option value="23">Laser Rifle</option>
<option value="24">Drink Dispenser</option>
</select>
<select name="supplier[3]" onchange="supplier.select.change(this);">
<option value="" selected="selected">--none--</option>
<option value="23">Sonic Disrupter</option>
<option value="24">Back Scratcher</option>
</select>
<select name="supplier[4]" onchange="supplier.select.change(this);">
<option value="" selected="selected">--none--</option>
<option value="23">Tactical Nuke</option>
<option value="24">Food Replicator</option>
</select>
</form>
window.onload = function(){
supplier.select.load();
}
// ONLOAD
function addOnload(func) {
var oldonload = window.onload;
if(typeof window.onload != 'function'){
window.onload = func;
}
else {
window.onload = function(){
oldonload();
func();
}
}
}
function loader(){
supplier.select.load();
}
addOnload(loader);
self.event = {
'addonload': function(func){
var oldonload = window.onload;
if(typeof window.onload != 'function'){
window.onload = func;
}
else {
window.onload = function(){
oldonload();
func();
}
}
}
};
supplier.event.addonload(
function(){
supplier.select.load();
}
);
<form name="new_pro" method="post" onsubmit="return validate_form(this)"
method="post" enctype="multipart/form-data">
<select name="mode" onchange="supplier.select.change(this);">
<option value="manual">Manual Mode</option>
<option value="automatic">Automatic Mode</option>
</select>
<select name="supplier[1]" onchange="supplier.select.change(this);">
<option value="" selected="selected">--none--</option>
<option value="23">Combat Robot</option>
<option value="24">Servant Robot</option>
</select>
<select name="supplier[2]" onchange="supplier.select.change(this);">
<option value="" selected="selected">--none--</option>
<option value="23">Laser Rifle</option>
<option value="24">Drink Dispenser</option>
</select>
<select name="supplier[3]" onchange="supplier.select.change(this);">
<option value="" selected="selected">--none--</option>
<option value="23">Sonic Disrupter</option>
<option value="24">Back Scratcher</option>
</select>
<select name="supplier[4]" onchange="supplier.select.change(this);">
<option value="" selected="selected">--none--</option>
<option value="23">Tactical Nuke</option>
<option value="24">Food Replicator</option>
</select>
</form>
<script type="text/javascript">
function changeindex(thisselect){
var supplier = new function(){
Error: missing } after function body
Source File: http://www.example.com/page.php?cPath=640&pID=12378&action=new_pro
Line: 109, Column: 1
}
Error: supplier is not defined
Source File: http://www.example.com/page.php?cPath=640&pID=12378&action=new_pro
Line: 1
Did it work "outside" of your project? Meaning, when you copied & pasted it into it's own html file and run in the browser, did it work?
<script type="text/javascript">
function changeindex(thisselect){
var supplier = new function(){
self = this;
self.select = {
'dropdown': [],
'which': '',
'mode': false,
'load': function(){
this.dropdown = document.getElementsByTagName('select');
this.reset();
},
'change': function(select){
this.which = select.options[select.selectedIndex];
if(select.name == 'mode'){
this.mode = (this.which.value == 'manual') ? false : true;
}
if(!this.mode){return}
this.changeindex();
},
'changeindex': function(){
for(var i = 0; i < this.dropdown.length; i++){
if(this.dropdown[i].name == 'mode'){
i++;
}
if(this.dropdown[i].name != this.which.name){
for(var j = 0; j < this.dropdown[i].options.length; j++){
if(this.dropdown[i].options[j].value == this.which.value){
this.dropdown[i].options[j].selected = true;
}
}
}
}
},
'reset': function(){
for(var i = 0; i < this.dropdown.length; i++){
this.dropdown[i].options[0].selected = true;
}
}
};
};
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{
alert(alerttxt);return false;
}
else
{
return true;
}
}
}
function validate_form(thisform)
{
with (thisform)
{
if (validate_required(products_price,"Price cannot be left blank!")==false)
{
products_price.focus();
return false;
} else return true;
}
}
</script>
</head> echo tep_draw_form('new_pro', FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=new_pro_preview&editstatus=adminmode" onsubmit="return validate_form(this)"', 'post', 'enctype="multipart/form-data"'); echo str_replace('"','"',tep_draw_pull_down_menu('supplier[' . $values['products_options_values_id'] . ']"'.'onchange="supplier.select.change(this);"', $manufacturers2_array, $attributes['supplier']));
<script type="text/javascript">
var supplier = new function(){
self = this;
self.select = {
'dropdown': [],
'which': '',
'mode': false,
'load': function(){
this.dropdown = document.getElementsByTagName('select');
this.reset();
},
'change': function(select){
this.which = select.options[select.selectedIndex];
if(select.name == 'mode'){
this.mode = (this.which.value == 'manual') ? false : true;
}
if(!this.mode){return}
this.changeindex();
},
'changeindex': function(){
for(var i = 0; i < this.dropdown.length; i++){
if(this.dropdown[i].name == 'mode'){
i++;
}
if(this.dropdown[i].name != this.which.name){
for(var j = 0; j < this.dropdown[i].options.length; j++){
if(this.dropdown[i].options[j].value == this.which.value){
this.dropdown[i].options[j].selected = true;
}
}
}
}
},
'reset': function(){
for(var i = 0; i < this.dropdown.length; i++){
this.dropdown[i].options[0].selected = true;
}
}
};
};
window.onload = function(){
supplier.select.load();
}
function validate_required(field,alerttxt){
with(field){
if(value == null || value == ''){
alert(alerttxt);return false;
}
else {
return true;
}
}
}
function validate_form(thisform){
with(thisform){
if(!validate_required(products_price, 'Price cannot be left blank!')){
products_price.focus();
return false;
}
return true;
}
}
</script>
<select name="mode" onchange="supplier.select.change(this);">
<option value="manual">Manual Mode</option>
<option value="automatic">Automatic Mode</option>
</select>
<select name="mode" onchange="supplier.select.change(this);">
<option value="manual">Manual Mode</option>
<option value="automatic">Automatic Mode</option>
</select> <select name="mode" onchange="supplier.select.change(this);">
<option value="manual">Manual Mode</option>
<option value="automatic">Automatic Mode</option>
</select>
<?php
$rows = 0;
$options_query = tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . $languages_id . "' order by products_options_id");
while ($options = tep_db_fetch_array($options_query)) {
$values_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pov.order_value from " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " p2p where pov.products_options_values_id = p2p.products_options_values_id and p2p.products_options_id = '" . $options['products_options_id'] . "' and pov.language_id = '" . $languages_id . "' order by pov.order_value");
$header = false;
while ($values = tep_db_fetch_array($values_query)) {
$rows ++;
if (!$header) {
$header = true;
?>
<td colspan="2"><font color="#898400"><i><b><?php echo $options['products_options_name']; ?></b></i></font></td>
<td><font color="#898400"><i><b>Qty</b></i></font></td>
<td><font color="#898400"><i><b>Location</b></i></font></td>
<td><font color="#898400"><i><b>SKU</b></i></font></td>
<td width="30"></td>
<td colspan="3"><font color="#898400"><i><b>Addl. Cost</b></i></font></td>
</tr>
<?php
}
$attributes = array();
if (sizeof($HTTP_POST_VARS) > 0) {
if ($HTTP_POST_VARS['option'][$rows]) {
$attributes = array('products_attributes_id' => $HTTP_POST_VARS['option'][$rows],
'options_values_price' => $HTTP_POST_VARS['price'][$rows],
'price_prefix' => $HTTP_POST_VARS['prefix'][$rows],
'attribute_sort' => $HTTP_POST_VARS['attribute_sort'][$rows],
'quantity' => $HTTP_POST_VARS['quantity'][$rows],
'supplier' => $HTTP_POST_VARS['supplier'][$rows],
'location' => $HTTP_POST_VARS['location'][$rows]);
}
} else {
$attributes_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix, attribute_sort, quantity, supplier, location from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $pInfo->products_id . "' and options_id = '" . $options['products_options_id'] . "' and options_values_id = '" . $values['products_options_values_id'] . "'");
if (tep_db_num_rows($attributes_query) > 0) {
$attributes = tep_db_fetch_array($attributes_query);
}
}
?>
<tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
<td><?php echo tep_draw_checkbox_field('option[' . $values['products_options_values_id'] . ']', $attributes['products_attributes_id'], $attributes['products_attributes_id']) . ' ' . $values['products_options_values_name']; ?> </td>
<td><?php echo tep_draw_hidden_field('attribute_sort[' . $values['products_options_values_id'] . ']', $values['order_value'], 'size="1"'); ?></td>
<td><?php echo tep_draw_input_field('quantity[' . $values['products_options_values_id'] . ']', $attributes['quantity'], 'size="1"'); ?></td>
<td><?php echo str_replace('"','"',tep_draw_pull_down_menu('supplier[' . $values['products_options_values_id'] . ']"'.'onchange="supplier.select.change(this);"', $manufacturers2_array, $attributes['supplier']));?></td>
<td><?php echo tep_draw_input_field('location[' . $values['products_options_values_id'] . ']', $attributes['location'], 'size="6"'); ?></td>
<td></td>
<!-- <td><?php echo tep_draw_input_field('prefix[' . $values['products_options_values_id'] . ']', $attributes['price_prefix'], 'size="2"'); ?></td>--!>
<td><?php //populate attributes + / -
$attribute_addon_selection = array(array('id' => '', 'text' => 'n/a'),
array('id' => '+', 'text' => '+'),
array('id' => '-', 'text' => '-'));
echo tep_draw_pull_down_menu('prefix[' . $values['products_options_values_id'] . ']', $attribute_addon_selection, $attributes['price_prefix']); ?></td>
<td><?php echo tep_draw_input_field('price[' . $values['products_options_values_id'] . ']', $attributes['options_values_price'], 'size="1"'); ?></td>
</tr>
<?php
}
}
?>
Error: supplier is not defined
Line: 1
<?
if ($_GET['read'] != "only") {
switch($_GET['action']){
case 'new_product_preview':
$onload = isset($_GET['pID']) ? 'document.update_product.submit();' : 'document.insert_product.submit();';
break;
case 'new_master_preview':
$onload = isset($_GET['pID']) ? 'document.update_master.submit();' : 'document.insert_master.submit();';
break;
default:
$onload = 'SetFocus();';
break;
}
} else {
$onload = 'SetFocus();';
}
?>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="<? echo $onload; ?>"> <script type="text/javascript">
var supplier = new function(){
self = this;
self.event = {
'addonload': function(func){
var oldonload = window.onload;
if(typeof window.onload != 'function'){
window.onload = func;
}
else {
window.onload = function(){
oldonload();
func();
}
}
}
};
self.select = {
'dropdown': [],
'which': '',
'mode': false,
'load': function(){
this.dropdown = document.getElementsByTagName('select');
this.reset();
},
'change': function(select){
this.which = select.options[select.selectedIndex];
if(select.name == 'mode'){
this.mode = (this.which.value == 'manual') ? false : true;
}
if(!this.mode){return}
this.changeindex();
},
'changeindex': function(){
for(var i = 0; i < this.dropdown.length; i++){
if(this.dropdown[i].name == 'mode'){
i++;
}
if(this.dropdown[i].name != this.which.name){
for(var j = 0; j < this.dropdown[i].options.length; j++){
if(this.dropdown[i].options[j].value == this.which.value){
this.dropdown[i].options[j].selected = true;
}
}
}
}
},
'reset': function(){
for(var i = 0; i < this.dropdown.length; i++){
this.dropdown[i].options[0].selected = true;
}
}
};
};
supplier.event.addonload(
function(){
supplier.select.load();
}
);
function validate_required(field,alerttxt){
with(field){
if(value == null || value == ''){
alert(alerttxt);return false;
}
else {
return true;
}
}
}
function validate_form(thisform){
with(thisform){
if(!validate_required(products_price, 'Price cannot be left blank!')){
products_price.focus();
return false;
}
return true;
}
}
</script>
Message: Not implemented
Line: 26
Char: 5
Code: 0
self = this; which is right beneath: var supplier = new function(){
function changeindex(thisselect){ Message: 'supplier' is undefined
Line: 697
Char: 1
Code: 0
<select name="mode" onchange="supplier.select.change(this);"> need an array info? Like: <select name="mode" onchange="supplier[j].select.change(this);">