News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Chained Fields

Started by maxi1973, November 05, 2012, 08:35:34 AM

Previous topic - Next topic

maxi1973

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

PRO


maxi1973

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?

PRO




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

maxi1973

Well. In your example i have to change text1 and text2 with the label of my custom fields, right? Thanks a lot!!

maxi1973

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!!

PRO

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);