VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: maxi1973 on November 05, 2012, 08:35:34 AM

Title: Chained Fields
Post by: maxi1973 on November 05, 2012, 08:35:34 AM
Hello everybody, i'm searching a solution to make chained field...
For example: i create a filed radio type with two options "private" and "business"; well i need, if client choose "private", a field like "privatetext" will appear in registration; otherwise if client choose "business", the field "privatetext" disappear and appear another field, "businesstext".
Thanks to everyone can help me.
Max
P.S. i'm using VM 2.0.12f and joomla 2.5.7
Title: Re: Chained Fields
Post by: PRO on November 05, 2012, 13:09:39 PM
will this help?

http://breakdesigns.net/extensions/vm-product-builder
Title: Re: Chained Fields
Post by: maxi1973 on November 05, 2012, 13:57:51 PM
Hello Pro, and thank you for your help.
Unfortunately it's not necessary to me.
I'm searching a solution for customer registration , not for products customization. Maybe someone have a solution?
Title: Re: Chained Fields
Post by: PRO on November 05, 2012, 18:20:45 PM



You can do this with a little jquery and css


something like this

<?php if (JRequest::getVar('addrtype')=='BT')   {
$document = JFactory::getDocument();
$document->addScriptDeclaration("
   jQuery(document).ready(function($) {
   $('.text1').hide();
      $('.button1').click(function () {
$('text1').show('slow');
});
   });
");
}
?>

<?php if (JRequest::getVar('addrtype')=='BT')   {
$document = JFactory::getDocument();
$document->addScriptDeclaration("
   jQuery(document).ready(function($) {
   $('.text2').hide();
      $('.button2').click(function () {
$('text2').show('slow');
});
   });
");
}
?>

I do a little something like this in my checkout for guest checkout, to hide password and username fields, when they click a "guest" button

You just have to add the html


views/user/edit_address_userfields.php
Title: Re: Chained Fields
Post by: maxi1973 on November 05, 2012, 19:12:16 PM
Well. In your example i have to change text1 and text2 with the label of my custom fields, right? Thanks a lot!!
Title: Re: Chained Fields
Post by: maxi1973 on November 05, 2012, 19:18:50 PM
If radio selection is "buttonradio" with two options, "private" and "business" and the two fields are "privatename" (to show if radio selection is "private") and "businessname" (to show if radio selection is "business").
Can you kindly explain how to configure the code you have posted before? thanks in advance, thanks thanks thanks!!
Title: Re: Chained Fields
Post by: PRO on November 05, 2012, 19:22:05 PM
Quote from: maxi1973 on November 05, 2012, 19:12:16 PM
Well. In your example i have to change text1 and text2 with the label of my custom fields, right? Thanks a lot!!


You have to add a class to the button.

For yours, if you want to actually use the "custom fields" like dropdown etc. You are going to have to change the selector

like i do this for payment method page
$('input:#payment_id_11').show('slow);