Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / Required Attribute Radio Fields

Required Attribute Radio Fields

Views: 835

Results 1 to 9 of 9
19 Mar 2013, 12:49 PM
#1
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Required Attribute Radio Fields

Hope I can explain what I am trying to accomplish here.

I have an Attribute Dropdown with options A & B
I have (2) Attribute Radio Fields A1 and B1

If option A is selected:
A1 is REQUIRED

If option B is selected:
B1 is REQUIRED

I know Zen Cart does not support Dependent Attributes, I have written code to allow dependent attributes but can not figure out the radio button REQUIRED aspect.

Any suggestions?

19 Mar 2013, 4:39 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Required Attribute Radio Fields

If option A is selected:
A1 is REQUIRED

If option B is selected:
B1 is REQUIRED
Why have radio buttons at all if it is always required??

19 Mar 2013, 5:06 PM
#3
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Required Attribute Radio Fields

Has to be customer initiated (acknowledged) like the "checkbox" on the checkout page for agreeing to conditions of use.

Zen cart does not allow checkbox attributes to be required.

19 Mar 2013, 11:50 PM
#4
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Required Attribute Radio Fields

rbarbour:

Hope I can explain what I am trying to accomplish here.

I have an Attribute Dropdown with options A & B
I have (2) Attribute Radio Fields A1 and B1

If option A is selected:
A1 is REQUIRED

If option B is selected:
B1 is REQUIRED

I know Zen Cart does not support Dependent Attributes, I have written code to allow dependent attributes but can not figure out the radio button REQUIRED aspect.

Any suggestions?

Try this...

Create THREE radio option VALUES:

COLOR="#FF0000"[/COLOR] Please make a selection...
COLOR="#FF0000"[/COLOR] A1
COLOR="#FF0000"[/COLOR] B1

Make COLOR="#FF0000"[/COLOR] DISPLAY ONLY and DEFAULT (in attributes controller).

Then, use firebug to establish the element ID of the INPUT for COLOR="#FF0000"[/COLOR]...

It will be something like: input#attrib-1-1

Then, in stylesheet.css add ...

input#attrib-1-1 {visibility:hidden;}

This hides the radio button for the display only default option (Please make a selection...), and forces a choice of A1 / B1

20 Mar 2013, 2:54 AM
#5
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Required Attribute Radio Fields

schoolboy:

Try this...

Create THREE radio option VALUES:

COLOR=#FF0000[/COLOR] Please make a selection...
COLOR=#FF0000[/COLOR] A1
COLOR=#FF0000[/COLOR] B1

Make COLOR=#FF0000[/COLOR] DISPLAY ONLY and DEFAULT (in attributes controller).

Then, use firebug to establish the element ID of the INPUT for COLOR=#FF0000[/COLOR]...

It will be something like: input#attrib-1-1

Then, in stylesheet.css add ...

input#attrib-1-1 {visibility:hidden;}

This hides the radio button for the display only default option (Please make a selection...), and forces a choice of A1 / B1

I'm familiar with all that, I appoligize you spent the time schoolboy :-)

I should have explained the issue I was having was in the javascript. If A1 /B1 is not ticked, it gives the error but doesnt save the rest of the attribute inputs (selects, text, and checkboxes).

20 Mar 2013, 4:23 AM
#6
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Required Attribute Radio Fields

I figured it out, dependable attributes!

20 Mar 2013, 6:51 AM
#7
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Re: Required Attribute Radio Fields

And how do you make that work ?

20 Mar 2013, 7:20 AM
#8
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Required Attribute Radio Fields

rbarbour:

I figured it out, dependable attributes!

Yes... if you reveal that to all of us we will put you forward for the next position of Pope - or perhaps even God himself.:D

20 Mar 2013, 10:40 PM
#9
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Required Attribute Radio Fields

schoolboy:

Yes... if you reveal that to all of us we will put you forward for the next position of Pope - or perhaps even God himself.:D

I am not that good.

I figured it out, dependable attributes!

I figured out dependable attributes for the situation at hand, it does include the dropdown, checkbox, text and radio fields.