|
Enable/Disable checkbox
|
| Author |
Message |
Son Goku
Novi korisnik

Posts: 20
Group: Registered
Joined: Jan 2008
Status:
Offline
Reputation: 0
|
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:
<td><input name="ime" type="text" /></td>
<td><input type="checkbox" name="checkbox1" disabled/></td>
|
|
| 06-05-2008 01:09 PM |
|
 |
Gogy
____

Posts: 1,729
Group: Webmaster
Joined: Feb 2006
Status:
Offline
|
RE: enable checkbox
U head dio:
function vrijednost(tekst)
{
if(tekst=="")
{
cbox = document.getElementById("checkbox");
cbox.checked = false;
}
else
{
cbox.checked=true;
}
}
A u body dio:
<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 |
|
 |
Son Goku
Novi korisnik

Posts: 20
Group: Registered
Joined: Jan 2008
Status:
Offline
Reputation: 0
|
RE: enable checkbox
Hvala na brzom odgovoru :)
ali ne radi mi, mozda sam nesto fulao:
<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 |
|
 |
Gogy
____

Posts: 1,729
Group: Webmaster
Joined: Feb 2006
Status:
Offline
|
RE: enable checkbox
Nisi, sorry, ja sam krivo razumio pitanje.... Stavio sam ti checkiranje umjesto enable/disable. Evo koda.
<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 |
|
 |
Son Goku
Novi korisnik

Posts: 20
Group: Registered
Joined: Jan 2008
Status:
Offline
Reputation: 0
|
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:
<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 |
|
 |
Gogy
____

Posts: 1,729
Group: Webmaster
Joined: Feb 2006
Status:
Offline
|
RE: enable checkbox
Evo primjera:
<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 |
|
 |
Son Goku
Novi korisnik

Posts: 20
Group: Registered
Joined: Jan 2008
Status:
Offline
Reputation: 0
|
RE: Enable/Disable checkbox
odlicno, puno hvala sefe
|
|
| 06-05-2008 03:28 PM |
|
 |
Gogy
____

Posts: 1,729
Group: Webmaster
Joined: Feb 2006
Status:
Offline
|
|
| 06-05-2008 03:43 PM |
|
 |