X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   General questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=66)
-   -   Product Combo Box Issue (https://forum.x-cart.com/showthread.php?t=74211)

Joshshift 07-15-2016 12:43 PM

Product Combo Box Issue
 
it used to be in xcart 4 there was a Validation script (JavaScript) box, for which i input something like this:

if (document.getElementById('po573').selectedIndex== 0) {alert('Please select your color.');
return false;}
if (document.getElementById('po574').selectedIndex== 0) {alert('Please select your size.');
return false;}

so i would make the default combo box selection something like:
Please Select...

and if they didnt change the combo box it would throw the customer a message saying make a selection. how is this achieved in xcart5?

Core version: 5.2.15

cflsystems 07-15-2016 01:07 PM

Re: Product Combo Box Issue
 
XC5 should be using HTML5 out of the box and this is easily done with simple HTML5 rules. No js required.
Unfortunately I don't think XC5 is coded to take advantage of this so you will have to do this yourself via a custom module.
Basically it comes down to adding new <option> tag as first one in the <select> and setting its properties as below

Code:

<select>
<option disabled value="" selected>Please Select</option>
<option>1</option>
<option>2</option>
........
</select>


Here is live example - https://www.cflsystems.com/site-structured-data-for-x-cart-5.html
It is on XC4 but the idea is the same

Joshshift 07-18-2016 06:59 AM

Re: Product Combo Box Issue
 
wouldnt that effect every combo box though?
some combo boxes start at a default that doesnt need to be changed, then wouldnt the default value not be selectable?

cflsystems 07-18-2016 07:32 AM

Re: Product Combo Box Issue
 
It will affect all of them yes but you can limit which ones are affected with your custom module. In XC5 you can't just go an change some code - it has to be done with a module or you lose changes on next upgrade.
Also - this will not have any affect on which option is selected on page load if its value is passed. It will only be the first one to start with if no option is selected by default.


All times are GMT -8. The time now is 08:50 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.