Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
checklenght() dva puta..., ili-kako jednu funkciju pozvati d

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Client-side
View previous topic :: View next topic  
Author Message
blackshtef
mi3.crew


Joined: 14 Sep 2003
Posts: 661

PostPosted: 20.02.2006 15:45    Post subject: checklenght() dva puta..., ili-kako jednu funkciju pozvati d Add user to your forum ignore list Reply with quote

Imam sljedeći JavaScript kôd:

Code:
function checklenght() {
   if (document.ime_forme.poruka.value.length > 1000) {
     alert ("Neki error...");
     document.ime_forme.poruka.value = document.ime_forme.poruka.value.substring (0, 1000);
    }
   else {
     document.ime_forme.preostalo.value = 1000 - document.ime_forme.poruka.value.length;
    }
}

function checklenght() {
   document.ime_forme.napisano.value = 0 + document.ime_forme.poruka.value.length;
    }


Gornji dio skripte (if else) prati text box u kojeg se kuca tekst. Ispod tog text boxa se nalaze dva text fielda. Jedan prikazuje broj preostalih znakova, drugi prikazuje broj napisanih znakova u text boxu. Sam broj znakova u text boxu ograničen je gornjom funkcijom:

Code:
if (document.ime_forme.poruka.value.length > 1000) {
     alert ("Neki error...");...



Text fieldovi imaju u sebi onfocus="preostalo.blur();" i onfocus="napisano.blur();".

I tu se dolazi do problema, radi mi samo onaj koji prikazuje broj napisanih znakova, dok ovaj drugi (preostalo) stoji na 1000... a trebali bi obadva brojat, jedan prema gore, drugi dolje...shvaćate na šta ciljam?

Vjerujem da je sam kôd skripte, odnosno funkcije, da su dobro napisane, jer kad jednu maknem, druga radi, ali ih ne mogu natjerati da obe istovremeno rade...
Pretpostavljam da je to zbog toga što se dva put poziva funkcija checklenght(), jel je?

Kako to riješit? Kak da natjeram da obe rade?
Back to top
View user's profile Send private message Send e-mail MSN Messenger
retro_one



Joined: 16 Sep 2003
Posts: 880
Location: DUBRAVA.

PostPosted: 20.02.2006 16:05    Post subject: Add user to your forum ignore list Reply with quote

pa naravno da ti ne mogu se zvati dvije funkcije isto.....

napravi to tako da iz jedne pozivas drugu funkciju i rijesio si problem

_________________
Just your average eccentric programmer.
Back to top
View user's profile Send private message
blackshtef
mi3.crew


Joined: 14 Sep 2003
Posts: 661

PostPosted: 20.02.2006 16:22    Post subject: Add user to your forum ignore list Reply with quote

Još zaboravih napisati...
taj textarea ima onkeyup="checklenght" onkeydown="checklenght"...on u biti poziva funkciju, a ova dva textfielda imaju onfocus="napisano.blur()" i onfocus="preostalo.blur()"
Back to top
View user's profile Send private message Send e-mail MSN Messenger
retro_one



Joined: 16 Sep 2003
Posts: 880
Location: DUBRAVA.

PostPosted: 20.02.2006 16:26    Post subject: Add user to your forum ignore list Reply with quote

ma gle...ne mozes imati dvije funkcije s istim imenom.

_________________
Just your average eccentric programmer.
Back to top
View user's profile Send private message
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 20.02.2006 17:49    Post subject: Add user to your forum ignore list Reply with quote

ajme otrovat ću se sa "lenght"... Sad daj to ispravi u "length"
Back to top
View user's profile Send private message Send e-mail Visit poster's website
blackshtef
mi3.crew


Joined: 14 Sep 2003
Posts: 661

PostPosted: 20.02.2006 18:00    Post subject: Add user to your forum ignore list Reply with quote

RIJEŠIO! Very Happy
Dakle...retro, fala na pomoći, neke stvari doslovno treba prespavati...jebote, cijelu noć sam se s tim patio...i tek sad vidim u čem je greška Rolling Eyes

Dakle...krivi kôd
Code:
function checklength() {
   if (document.ime_forme.poruka.value.length > 1000) {
     alert ("Neki error...");
     document.ime_forme.poruka.value = document.ime_forme.poruka.value.substring (0, 1000);
    }
   else {
     document.ime_forme.preostalo.value = 1000 - document.ime_forme.poruka.value.length;
    }
}

function checklenght() {
   document.ime_forme.napisano.value = 0 + document.ime_forme.poruka.value.length;
    }

Ispravio ht u th Smile

Pravilan kôd
Code:
function checklength() {
   if (document.ime_forme.poruka.value.length > 1000) {
     alert ("Neki error...");
     document.ime_forme.poruka.value = document.ime_forme.poruka.value.substring (0, 1000);
    }
   else {
     document.ime_forme.preostalo.value = 1000 - document.ime_forme.poruka.value.length;
document.ime_forme.napisano.value = 0 + document.ime_forme.poruka.value.length;
    }
}


Eto Smile
Sad može lokot na topic Smile
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 20.02.2006 19:56    Post subject: Add user to your forum ignore list Reply with quote

zakaj lokot... možda bi još netko htio neš pitat
Back to top
View user's profile Send private message Send e-mail Visit poster's website
blackshtef
mi3.crew


Joined: 14 Sep 2003
Posts: 661

PostPosted: 20.02.2006 22:42    Post subject: Add user to your forum ignore list Reply with quote

ma to ja samo tak velim Smile
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Client-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group