Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Javascript problem in Firefox


digicammad

Recommended Posts

Posted

The following code displays an alert and won't allow a product to be added to the basket if the product options have not been specified. It works fine in IE but Firefox just sails through and adds the product to the basket. Are there any js experts out there who could tell me how to fix it?

 

---------- Code ------------------

 

<script language="javascript"><!--

 

function BadOption(name, defaultvalue, message)

{

var element = document.getElementById(name);

if(element != null){

if (element.value == defaultvalue) {

alert(message);

element.focus();

return true;

}

}

return false;

}

 

function validate() {

 

 

if( BadOption('id[6]', 36, 'Please select a collar size before adding your product to the shopping basket'))

return false;

 

if( BadOption('id[1]', 37, 'Please select a colour before adding your product to the shopping basket'))

return false;

 

if( BadOption('id[5]', 38, 'Please select a finish before adding your product to the shopping basket'))

return false;

 

if( BadOption('id[3]', 39, 'Please select a module size before adding your product to the shopping basket'))

return false;

 

if( BadOption('id[4]', 40, 'Please select a size before adding your product to the shopping basket'))

return false;

 

if( BadOption('id[2]', 41, 'Please select a strap length before adding your product to the shopping basket'))

return false;

 

return true;

}

Posted

Enable javascript in Firefox? Include a <noscript> function which will only show if javascript is not enabled?

 

You can't make a javascript function work if javascript is not enabled in the browser you are using, so the <noscript> function will have to be based on something other than javascript.

 

Vger

Archived

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

×
×
  • Create New...