Post Reply  Post Thread 
Enable/Disable checkbox
Author Message
Son Goku
Novi korisnik
*


Posts: 20
Group: Registered
Joined: Jan 2008
Status: Offline
Reputation: 0
Post: #1
Smile  Enable/Disable checkbox

Pozdrav.
Imam textfield i pokraj njega checkbox, i htio bi da mi checkbox bude disabled sve dok ne upisem bar jedno slovo ili broj u taj textfield. Ako netko zna kako se to radi? Hvala

Evo npr. ovako nekako mi to izgleda:

Code:
<td><input name="ime" type="text" /></td>
<td><input type="checkbox" name="checkbox1" disabled/></td>

06-05-2008 01:09 PM
Find all posts by this user Quote this message in a reply
Gogy
____
*


Posts: 1,729
Group: Webmaster
Joined: Feb 2006
Status: Offline
Post: #2
RE: enable checkbox

U head dio:

Code:
function vrijednost(tekst)
       {
        if(tekst=="")
        {
                cbox = document.getElementById("checkbox");
                cbox.checked = false;
        }
        
        else
        {
                cbox.checked=true;
        }
      }


A u body dio:

Code:
<td><input name="ime" type="text" id="polje" onBlur="vrijednost(this.value);"/></td>
<td><input type="checkbox" name="checkbox1" id="checkbox"></td>


Pravila foruma

eBooks Network - download besplatnih e-knjiga
06-05-2008 01:29 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Son Goku
Novi korisnik
*


Posts: 20
Group: Registered
Joined: Jan 2008
Status: Offline
Reputation: 0
Post: #3
RE: enable checkbox

Hvala na brzom odgovoru :)
ali ne radi mi, mozda sam nesto fulao:

Code:
<html>

<head>
<script type="text/javascript">
function vrijednost(tekst)
       {
        if(tekst=="")
        {
                cbox = document.getElementById("checkbox");
                cbox.checked = false;
        }
        
        else
        {
                cbox.checked=true;
        }
      }
</script>
</head>

<body>
<table>
<tr>
<td><input name="ime" type="text" id="polje" onBlur="vrijednost(this.value);"/></td>
<td><input type="checkbox" name="checkbox1" id="checkbox"></td>
</tr>
</table>
</body>

</html>

06-05-2008 01:49 PM
Find all posts by this user Quote this message in a reply
Gogy
____
*


Posts: 1,729
Group: Webmaster
Joined: Feb 2006
Status: Offline
Post: #4
RE: enable checkbox

Nisi, sorry, ja sam krivo razumio pitanje.... Stavio sam ti checkiranje umjesto enable/disable. Evo koda.

Code:
<html>
<head>
<title> www.tutorijali.net </title>
<script type="text/javascript">
function vrijednost(tekst)
    {
        if(tekst!="")
        {
                cbox = document.getElementById("checkbox");
                cbox.disabled = false;
        }
        
        else
        {
            cbox.disabled = true;
        }
    }
</script>
</head>

<body>
<td><input name="ime" type="text" id="polje" onBlur="vrijednost(this.value);" /></td>
<td><input type="checkbox" name="checkbox1" id="checkbox" disabled="true" /></td>
</body>
</html>


Pravila foruma

eBooks Network - download besplatnih e-knjiga
06-05-2008 01:59 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Son Goku
Novi korisnik
*


Posts: 20
Group: Registered
Joined: Jan 2008
Status: Offline
Reputation: 0
Post: #5
RE: enable checkbox

Hvala, super radi :)

Sorry, zaboravio sam reci da mi treba vise tih polja u formi, i svaka ima svoje ime npr checkbox1, checkbox2, checkbox3...
Znaci da mi na svakom polju posebno radi:

Code:
<html>
<head>
<title> www.tutorijali.net </title>
<script type="text/javascript">
function vrijednost(tekst)
    {
        if(tekst!="")
        {
                cbox = document.getElementById("checkbox");
                cbox.disabled = false;
        }
        
        else
        {
            cbox.disabled = true;
        }
    }
</script>
</head>

<body>
<td><input name="ime1" type="text" id="polje1" onBlur="vrijednost(this.value);" /></td>
<td><input type="checkbox" name="checkbox1" id="checkbox1" disabled="true" /></td>
<td><input name="ime2" type="text" id="polje2" onBlur="vrijednost(this.value);" /></td>
<td><input type="checkbox" name="checkbox2" id="checkbox2" disabled="true" /></td>
<td><input name="ime3" type="text" id="polj3e" onBlur="vrijednost(this.value);" /></td>
<td><input type="checkbox" name="checkbox3" id="checkbox3" disabled="true" /></td>
</body>
</html>

06-05-2008 02:18 PM
Find all posts by this user Quote this message in a reply
Gogy
____
*


Posts: 1,729
Group: Webmaster
Joined: Feb 2006
Status: Offline
Post: #6
RE: enable checkbox

Evo primjera:

Code:
<html>
<head>
<title> www.tutorijali.net </title>
<script type="text/javascript">
function promijeni(broj)
    {
        
        polje = document.getElementById("polje" + broj).value;
        cbox = document.getElementById("checkbox" + broj);
        
        if(polje!="")
        {
            cbox.disabled = false;
            
        }
        
        else
        {
            cbox.disabled = true;
        }
        
    }
</script>
</head>

<body>
<input name="ime" type="text" id="polje1" onChange="promijeni('1');" />
<input type="checkbox" name="checkbox1" id="checkbox1" disabled="true" />
<br />
<input name="ime" type="text" id="polje2" onChange="promijeni('2');" />
<input type="checkbox" name="checkbox2" id="checkbox2" disabled="true" />
</body>
</html>


Pravila foruma

eBooks Network - download besplatnih e-knjiga
06-05-2008 03:13 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Son Goku
Novi korisnik
*


Posts: 20
Group: Registered
Joined: Jan 2008
Status: Offline
Reputation: 0
Post: #7
RE: Enable/Disable checkbox

odlicno, puno hvala sefe

06-05-2008 03:28 PM
Find all posts by this user Quote this message in a reply
Gogy
____
*


Posts: 1,729
Group: Webmaster
Joined: Feb 2006
Status: Offline
Post: #8
RE: Enable/Disable checkbox

Nema problema, i drugi put Namigivanje


Pravila foruma

eBooks Network - download besplatnih e-knjiga
06-05-2008 03:43 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: