Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Jquery slide

  1. #1
    New Coder
    Join Date
    Jun 2010
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Jquery slide

    Hi

    This is my code to show/hide textarea when checkbox click

    how can i add jquery slide to textarea when it show and hide?

    PHP Code:
    <input type "checkbox" id "chk1" onclick "toggle(1)">
    <input type "checkbox" id "chk2" onclick "toggle(2)">
    <input type "checkbox" id "chk3" onclick "toggle(3)">
    <input type "checkbox" id "chk4" onclick "toggle(4)">
    <input type "checkbox" id "chk5" onclick "toggle(5)">

    <
    textarea id "t1" rows "4" cols "50" style="display:none">1</textarea>
    <
    textarea id "t2" rows "4" cols "50" style="display:none">2</textarea>
    <
    textarea id "t3" rows "4" cols "50" style="display:none">3</textarea>
    <
    textarea id "t4" rows "4" cols "50" style="display:none">4</textarea>
    <
    textarea id "t5" rows "4" cols "50" style="display:none">5</textarea>

    <
    script type "text/javascript">

    function 
    toggle(which){
    var 
    ta "t" which;
    var 
    box "chk" which
    if (document.getElementById(box).checked ) {
    document.getElementById(ta).style.display="block";
    }
    else {
    document.getElementById(ta).style.display="none";
    }
    }
    </script> 

    Sorry for language errors

    Thanks

  • #2
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,950
    Thanks
    9
    Thanked 724 Times in 718 Posts
    Here's one way:

    Code:
    $(document).ready(function(){
    	$('input[type=checkbox]').attr('checked', false).change(function(){//set all the checkboxes to unchecked on load, and add a change event...
    	     var ident = $(this).attr('id').match(/\d+$/);//...to extract the integer from the id...
    	     $('#t'+ ident).slideToggle();//...and display or hide the matching textarea with a slide
    	});
    })
    This removes the need for your onClick attributes as well.

  • #3
    New Coder
    Join Date
    Jun 2010
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks

    also can you help me with jquery copy to clipboard?

    this is the text area and i need to copy content into clipboard when click on text area

    PHP Code:
    <textarea id="tx" name='set1' cols='80' rows='10' onClick="ClipBoard();"><?=substr($result['SET1'],0,50)?></textarea>

  • #4
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,950
    Thanks
    9
    Thanked 724 Times in 718 Posts
    There's no native jQuery support for clipboard, although you'll probably find a plugin somewhere.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •