Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Kako napraviti za <textarea> limit?
Author Message
suad Offline
Novi korisnik
*

Posts: 68
Joined: Nov 2009
Reputation: 0
Post: #1
Kako napraviti za <textarea> limit?
Pozdrav.

Dali neko zna kako da napravim ili gdje ima da se skine free skripta za textarea limit

ja sam našo na netu ovu skriptu
Code:
<html>
<header>

<script src="jquery.js" type="text/javascript"></script>


</header>

<body>



<textarea class="word_count" rows="5" cols="40">poipiopipi</textarea>
<br/>
<span class="counter"></span><br />

<script type="text/javascript">
$(document).ready(function(){
    /**
     * Character Counter for inputs and text areas showing characters left.
     */
    $('.word_count').each(function(){
        //maximum limit of characters allowed.
        var maxlimit = 240;
        // get current number of characters
        var length = $(this).val().length;
        if(length >= maxlimit) {
            $(this).val($(this).val().substring(0, maxlimit));
            length = maxlimit;
        }
        // update count on page load
        $(this).parent().find('.counter').html( (maxlimit - length) + ' characters left');
        // bind on key up event
        $(this).keyup(function(){
        // get new length of characters
        var new_length = $(this).val().length;
        if(new_length >= maxlimit) {
                $(this).val($(this).val().substring(0, maxlimit));
                //update the new length
                new_length = maxlimit;
            }
        // update count
        $(this).parent().find('.counter').html( (maxlimit - new_length) + ' characters left');
        });
    });

});
</script>

</body>
</html>

al mi se ne svidja pošto imam više textarea polja na stranici.

Znali neko kakvu jednostavniju skriptu?

Hvala!
03-06-2011 02:09 PM
Find all posts by this user Quote this message in a reply
schmrz Offline
____
*

Posts: 567
Joined: Feb 2007
Post: #2
RE: Kako napraviti za <textarea> limit?
Code:
<textarea id="area1"></textarea>
<p id="counter_area1"></p>

<textarea id="area2"></textarea>
<p id="counter_area2"></p>

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" />
    var display = new Object();
    
    function forceLimit(elName, limit) {
        display[elName] = $("#counter_" + elName);
        
        $("#" + elName).keyup(function() {
            if (this.value.length > limit) {
                this.value = this.value.substr(0, limit);
            }
        
            display[elName].html(this.value.length + " of " + limit);
        });
    }
    
    forceLimit("area1", 10);
    forceLimit("area2", 20);
</script>

Možda bi bilo praktično da odvojiš ovo u poseban js fajl, pa da ti bude ovako:

Code:
<textarea id="area1"></textarea>
<p id="counter_area1"></p>

<textarea id="area2""></textarea>
<p id="counter_area2"></p>

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="textarea.limit.js"></script>
<script type="text/javascript" />
    forceLimit("area1", 10);
    forceLimit("area2", 20);
</script>

I have no drinking problems. I drink. Get drunk. Fall down. NO PROBLEM
Registered As Linux User #484215
Moj skromni blog
Savjet za buduće programere: ovdje
03-06-2011 06:23 PM
Find all posts by this user Quote this message in a reply
suad Offline
Novi korisnik
*

Posts: 68
Joined: Nov 2009
Reputation: 0
Post: #3
RE: Kako napraviti za <textarea> limit?
a dali neko zna gdje mogu skinuti jquery skriptu WYSIWYG Editor
koji ima image menager?

Hvala!
04-06-2011 02:23 AM
Find all posts by this user Quote this message in a reply
schmrz Offline
____
*

Posts: 567
Joined: Feb 2007
Post: #4
RE: Kako napraviti za <textarea> limit?
Imaš brdo tih WYSIWYG editora, tinyMCE je jedan od njih, samo malo progooglaj.

I have no drinking problems. I drink. Get drunk. Fall down. NO PROBLEM
Registered As Linux User #484215
Moj skromni blog
Savjet za buduće programere: ovdje
04-06-2011 04:15 PM
Find all posts by this user Quote this message in a reply
suad Offline
Novi korisnik
*

Posts: 68
Joined: Nov 2009
Reputation: 0
Post: #5
RE: Kako napraviti za <textarea> limit?
(04-06-2011 04:15 PM)schmrz Wrote:  Imaš brdo tih WYSIWYG editora, tinyMCE je jedan od njih, samo malo progooglaj.

ja al nema ni jedan image menager nako nešto kao wordpress.

Dali mi možeš reći kako da napravim image menager za tinymce?
04-06-2011 04:41 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)