Autor Zpráva
Mata
Profil *
Dobry,
mam taky mensi problem. Potrebujem mensi JavaScripik, ktory by mi osetril nasledujucu vec. Mam HTML, v ktorom mam
<tr align="left">
<td><select name='language1' class='SELECT' id='language1' title='Language'>
<option value='en' title='English'>English</option>
<option value='sk' title='Slovak'>Slovak</option>
<option value='cz' title='Czech'>Czech</option>
</select>
<b></b></td>

</tr>
<tr align="left">
<td><select name='language2' class='SELECT' id='language2' title='Language'>
<option value='en' title='English'>English</option>
<option value='sk' title='Slovak'>Slovak</option>
<option value='cz' title='Czech'>Czech</option>
</select></td>
</tr>
<tr align="left">
<td valign='top'><b><font face="Courier New, Courier, mono">Dictionary</font></b></td>

<td><input type='checkbox' name='ECTACO' value='ECTACO'>ECTACO<br>
<input type='checkbox' name='Slovnik' value='Slovnik.sk'><br>Slovnik.sk<br>
<input type='checkbox' name='Feeha' value='Feeha'><br>FEEHA!<br>
</td></tr><tr>
<td><input type="submit" value="Translate"></td>
</tr>

v selectoch mam jazyky, v chceckboxe slovniky. A potrebujem, aby mi podla zvolenej kombinacie jazykov, ostali "aktivne" len tie chceckboxy, ktore danu kombinaciu jazykov podporuju. Ked napr.
Ectaco - en-sk, sk-en
Slovnik sk-cz, cz-sk
feeha cz-en, en-cz
zivan
Profil
Pridej ke vsem checkboxum hornotu id a k selectum pridej onchange="setDict()" a pripis tam tu funkci.


<script>
function setDict()
{
var lng1 = document.getElementById('language1').value;
var lng2 = document.getElementById('language2').value;
var dEct = document.getElementById('ECTACO');
var dSlo = document.getElementById('Slovnik');
var dFee = document.getElementById('Feeha');

if (((lng1=='en') && (lng2=='sk')) || ((lng1=='sk') && (lng2=='en')))
{
dEct.disabled = false;
dSlo.disabled = true;
dFee.disabled = true;
return;
}
if (((lng1=='cz') && (lng2=='sk')) || ((lng1=='sk') && (lng2=='cz')))
{
dEct.disabled = true;
dSlo.disabled = false;
dFee.disabled = true;
return;
}
if (((lng1=='en') && (lng2=='cz')) || ((lng1=='cz') && (lng2=='en')))
{
dEct.disabled = true;
dSlo.disabled = true;
dFee.disabled = false;
return;
}
dEct.disabled = false;
dSlo.disabled = false;
dFee.disabled = false;
}
</script>
zivan
Profil
Pripadne to jde zjednodusit pomoci regularnich vyrazu



function setDict()
{
var lng1 = document.getElementById('language1').value;
var lng2 = document.getElementById('language2').value;
var dEct = document.getElementById('ECTACO');
var dSlo = document.getElementById('Slovnik');
var dFee = document.getElementById('Feeha');

var str = new String(lng1+lng2);
dEct.disabled = str.match('cz[^c][^z]|[^c][^z]cz');
dSlo.disabled = str.match('en[^e][^n]|[^e][^n]en');
dFee.disabled = str.match('sk[^s][^k]|[^s][^k]sk');

}
Mata
Profil *
dakujem:):):)uz to bezi, ako ma:)
Toto téma je uzamčeno. Odpověď nelze zaslat.

0