This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Show/Hide question


  1. christo
    Member

    Hi,
    Reference http://www.appnitro.com/forums/topic/checkbox-to-open-a-second-address-field?replies=6#post-8262.

    Wouldn't there be a problem if you have 2 separate forms with the same element id and li reference? Is there a need (and way to implement - if there is) to tell the script which form to apply this to?

    I realized this as I was adding the following to view-functions.php per the instruction as follows for 2 different forms form 9 and form 13.

    Your help would be appreciated.

    /*Form 9 Categories */
    $(document).ready(function(){
    $('#li_10').css('display','none');
    $('#li_11').css('display','none');
    $('#li_12').css('display','none');
    $('#li_13').css('display','none');
    $('#element_98_1').click(function(){
    $('#li_10').toggle();
    $('#li_11').toggle();
    $('#li_12').toggle();
    $('#li_13').toggle();
    });
    });
    /*Form 13 Hours of operation*/
    $(document).ready(function(){
    $('#li_10').css('display','none');
    $('#li_11').css('display','none');
    $('#li_12').css('display','none');
    $('#li_13').css('display','none');
    $('#element_37_1').click(function(){
    $('#li_10').toggle();
    $('#li_11').toggle();
    $('#li_12').toggle();
    $('#li_13').toggle();
    });
    });
    </script

    Posted 14 years ago #
  2. redityo

    Hi,

    Yes it's, if you need to define which form you need to apply, you can try to edit view-functions.php file and follow these steps :

    1. Go to line 1825 for this code :

    $form_markup = <<<EOT

    and put your javascript code exactly above that line like this :

    if ($_GET['id'] == 9) {
    		$custom_js =<<<EOT
    <script type="text/javascript" src="js/jquery/jquery-core.js"></script>
    <script>
    $(document).ready(function(){
    		$('#li_10').css('display','none');
    		$('#li_11').css('display','none');
    		$('#li_12').css('display','none');
    		$('#li_13').css('display','none');
    
    		$('#element_98_1').click(function(){
    			$('#li_10').toggle();
    			$('#li_11').toggle();
    			$('#li_12').toggle();
    			$('#li_13').toggle();
    		});
    	});
    </script>
    EOT;
    		} elseif ($_GET['id'] == 13) {
    		$custom_js =<<<EOT
    <script type="text/javascript" src="js/jquery/jquery-core.js"></script>
    <script>
    $(document).ready(function(){
    		$('#li_10').css('display','none');
    		$('#li_11').css('display','none');
    		$('#li_12').css('display','none');
    		$('#li_13').css('display','none');
    
    		$('#element_37_1').click(function(){
    			$('#li_10').toggle();
    			$('#li_11').toggle();
    			$('#li_12').toggle();
    			$('#li_13').toggle();
    		});
    	});
    </script>
    EOT;
    		}

    2. Go to around line 1871, you'll see this code :

    {$calendar_js}

    then change it to

    {$custom_js}
    {$calendar_js}

    MachForm Support

    Posted 14 years ago #
  3. christo
    Member

    Thanks very much for the reply. This is perfect!
    Take care!
    Chris

    Posted 14 years ago #
  4. Lobbyof
    Member

    Hi, has the location (line number) of the place to insert the above code changed since this was answered? I can't find the relevant line at position 1825 (or nearby)?

    Posted 11 years ago #
  5. yuniar

    the above is valid for version 2 only. If you are using v3.3 already, the line should be around line 4946


    MachForm Founder

    Posted 11 years ago #

RSS feed for this topic

Reply