Appnitro Software Forums » MachForm

dropdown list when select hide input type text field or disable

(9 posts)
  • Started 9 months ago by johntorre
  • Latest reply from turkmedia

  1. johntorre
    Member

    Is it possible to hide or disable 1 text area field when i select one of the option in my DROPDOWN LIST..

    Posted 9 months ago #
  2. Hi,

    I think your problem similar with this post :

    http://www.appnitro.com/forums/topic/drop-down-with-other-option?replies=2#post-5552

    Posted 9 months ago #
  3. johntorre
    Member

    hi Sir Redityo... from the solution you gave.. can i ask how can i add different function showtextbox2() in the specific element?

    for example

    if ($_GET['id'] == 1) {
    $add_event = 'onchange="javascript:showTextBox()"';

    }

    i just want to add another showtextbox2()
    for specific elements only. how to write that sir..

    something like this logic sir:

    if ($element->id)== '12' {
    $add_event = 'onchange="javascript:showTextBox(2)"';
    }

    Thank you...

    Posted 8 months ago #
  4. You need to change in java script section, for example your another text box id to be hide is "element_3" then the code should be like this:

    <script type="text/javascript">
    
    	{$add_jquery}
    
    	function showTextBox() {
    		//reset text box value
    		$('#element_1').val('');
    
    		//show hide the field
    		//change the value based on your "other" selection value
    		if ($('#element_2').val() == '2') {
    			$('#li_1').show();
    		} else  {
    			$('#li_1').hide();
    		}
    	}
    
    	function showTextBox2() {
    		//reset text box value
    		$('#element_3').val('');
    
    		//show hide the field
    		//change the value based on your "other" selection value
    		if ($('#element_2').val() == '2') {
    			$('#li_3').show();
    		} else  {
    			$('#li_3').hide();
    		}
    	}
    
    </script>

    after that you can call it like this

    if ($element->id== '12') {
    $add_event = 'onchange="javascript:showTextBox2()"';
    }
    Posted 8 months ago #
  5. johntorre
    Member

    Sir REDITYO your the best.. Thank you so much..

    Sir just to add for this topic and maybe will help this topic in future use. Heres the code for hiding and showing form field.


    <script type="text/javascript">

    function showTextBox() {

    if ($('#element_9').val() == '5') {
    $('#li_11').hide();
    $('#li_12').hide();
    $('#li_13').hide();
    $('#li_14').hide();
    $('#li_15').hide();
    $('#li_16').hide();
    $('#li_17').hide();
    $('#li_18').hide();
    $('#li_19').hide();
    $('#li_20').hide();
    $('#li_11').show();
    }
    else if ($('#element_9').val() == '6') {
    $('#li_11').hide();
    $('#li_12').hide();
    $('#li_13').hide();
    $('#li_14').hide();
    $('#li_15').hide();
    $('#li_16').hide();
    $('#li_17').hide();
    $('#li_18').hide();
    $('#li_19').hide();
    $('#li_20').hide();
    $('#li_11').show();
    }
    else if ($('#element_9').val() == '7') {
    $('#li_11').hide();
    $('#li_12').hide();
    $('#li_13').hide();
    $('#li_14').hide();
    $('#li_15').hide();
    $('#li_16').hide();
    $('#li_17').hide();
    $('#li_18').hide();
    $('#li_19').hide();
    $('#li_20').hide();
    $('#li_11').show();
    }
    else if ($('#element_9').val() == '9') {
    $('#li_11').hide();
    $('#li_12').hide();
    $('#li_13').hide();
    $('#li_14').hide();
    $('#li_15').hide();
    $('#li_16').hide();
    $('#li_17').hide();
    $('#li_18').hide();
    $('#li_19').hide();
    $('#li_20').hide();
    $('#li_20').show();
    }
    else if ($('#element_9').val() == '10') {
    $('#li_11').hide();
    $('#li_12').hide();
    $('#li_13').hide();
    $('#li_14').hide();
    $('#li_15').hide();
    $('#li_16').hide();
    $('#li_17').hide();
    $('#li_18').hide();
    $('#li_19').hide();
    $('#li_20').hide();
    $('#li_20').show();
    }

    else {
    $('#li_11').hide();
    $('#li_12').hide();
    $('#li_13').hide();
    $('#li_14').hide();
    $('#li_15').hide();
    $('#li_16').hide();
    $('#li_17').hide();
    $('#li_18').hide();
    $('#li_19').hide();
    $('#li_20').hide();
    }

    }
    </script>

  6. BUT SIR REDITYO is there anyway to make it short and smooth...
    heres the example but got an error when combining..

    <script type="text/javascript">
    function showTextBox2() {

    if ($('#element_12').val() == '1') {
    $('#li_19').show();
    $('#li_14').hide();
    $('#li_15').hide();
    $('#li_16').hide();
    $('#li_17').hide();
    $('#li_18').hide();
    $('#li_21').hide();
    $('#li_22').hide();
    }
    else if ($('#element_12').val() == 3, 4, 5, 6, 7) {
    $('#li_13').show();
    $('#li_14').hide();
    $('#li_15').hide();
    $('#li_16').hide();
    $('#li_17').hide();
    $('#li_18').hide();
    $('#li_19').hide();
    $('#li_21').hide();
    $('#li_22').hide();
    }
    else {

    $('#li_13').hide();
    $('#li_14').hide();
    $('#li_15').hide();
    $('#li_16').hide();
    $('#li_17').hide();
    $('#li_18').hide();
    $('#li_19').hide();
    $('#li_21').hide();
    $('#li_22').hide();
    }

    }
    </script>

Posted 8 months ago #
  • Hi Johntoree,

    Thank's to share .. and for make your conditional statement shorter, try to change the code from :

    else if ($('#element_12').val() == 3, 4, 5, 6, 7) {

    to

    else if ($('#element_12').val() == 3 ||
    $('#element_12').val() == 4 ||
    $('#element_12').val() == 5 ||
    $('#element_12').val() == 6 ||
    $('#element_12').val() == 7  {

    hope this help ..

    Posted 8 months ago #
  • johntorre
    Member

    THank you so much really help a lot.. by the way guys from the code given by SIR Redityo

    else if ($('#element_12').val() == 3 ||
    $('#element_12').val() == 4 ||
    $('#element_12').val() == 5 ||
    $('#element_12').val() == 6 ||
    $('#element_12').val() == 7 {

    just add ) to the last number to close it... thanks again..

    Posted 8 months ago #
  • Ups .. I missed it :) Thank's ..

    Posted 8 months ago #
  • turkmedia
    Member

    hi
    i dont understand where i change
    i change in includes/view-functions.php by the post http://www.appnitro.com/forums/topic/drop-down-with-other-option?replies=2#post-5552
    but dont work and IE has error when i change the dropdown list and dont hide

    how can i hide a dropdown choises when i select from another dropdown like gender
    if gender = male show item 1,2,3,4
    and if gender = female show item 5,6,7,8
    in a drop down
    i want you to make a full guide to hide a dropdown and hide choices of dropdown
    i am makeing a employ form and need this

    Posted 7 months ago #

  • RSS feed for this topic

    Reply

    You must log in to post.