A
amli lola
Thanks Lasse for your post, worked (with a little fix) perfect.
Now, I have a similar problem (again function needed) with this code
function selected(sjedalo)
{
if((sjedalo=="A01")&&(sjedala_selektirana[1]==0)&&(brojac<5))
{
if(sjedala_slobodna[1])
{
sjedala_selektirana[1]=1;
brojac++; // counter++
if (document.form2.s1.value == "")
document.form2.s1.value = "A01";
else if (document.form2.s2.value == "")
document.form2.s2.value = "A01";
else if (document.form2.s3.value == "")
document.form2.s3.value = "A01";
else if (document.form2.s4.value == "")
document.form2.s4.value = "A01";
else if (document.form2.s5.value == "")
document.form2.s5.value = "A01";
}
}
else if((sjedalo=="A01")&&(sjedala_selektirana[1]==1)&&(brojac>0))
{
if(sjedala_slobodna[1])
{
sjedala_selektirana[1]=0;
brojac--;
if (document.form2.s1.value == "A01")
document.form2.s1.value = "";
else if (document.form2.s2.value == "A01")
document.form2.s2.value = "";
else if (document.form2.s3.value == "A01")
document.form2.s3.value = "";
else if (document.form2.s4.value == "A01")
document.form2.s4.value = "";
else if (document.form2.s5.value == "A01")
document.form2.s5.value = "";
}
}
else if((sjedalo=="A02")&&(sjedala_selektirana[2]==0)&&(brojac<5))
{
if(sjedala_slobodna[2])
{
sjedala_selektirana[2]=1;
brojac++;
if (document.form2.s1.value == "")
document.form2.s1.value = "A02";
else if (document.form2.s2.value == "")
document.form2.s2.value = "A02";
else if (document.form2.s3.value == "")
document.form2.s3.value = "A02";
else if (document.form2.s4.value == "")
document.form2.s4.value = "A02";
else if (document.form2.s5.value == "")
document.form2.s5.value = "A02";
}
}
else if((sjedalo=="A02")&&(sjedala_selektirana[2]==1)&&(brojac>0))
{
if(sjedala_slobodna[2])
{
sjedala_selektirana[2]=0;
brojac--;
if (document.form2.s1.value == "A02")
document.form2.s1.value = "";
else if (document.form2.s2.value == "A02")
document.form2.s2.value = "";
else if (document.form2.s3.value == "A02")
document.form2.s3.value = "";
else if (document.form2.s4.value == "A02")
document.form2.s4.value = "";
else if (document.form2.s5.value == "A02")
document.form2.s5.value = "";
}
}
// it goes on until sjedalo=="A016"
// notice that each sjedalo has two 'else if's', one for
sjedala_selektirana=0 && brojac<5 and one for sjedala_selektirana=1 &&
brojac>0
and the only difference is here
// for first if
sjedala_selektirana[2]=1;
brojac++; // counter++
// for second if
sjedala_selektirana[2]=0;
brojac--; // counter--
Thank you again...
Now, I have a similar problem (again function needed) with this code
function selected(sjedalo)
{
if((sjedalo=="A01")&&(sjedala_selektirana[1]==0)&&(brojac<5))
{
if(sjedala_slobodna[1])
{
sjedala_selektirana[1]=1;
brojac++; // counter++
if (document.form2.s1.value == "")
document.form2.s1.value = "A01";
else if (document.form2.s2.value == "")
document.form2.s2.value = "A01";
else if (document.form2.s3.value == "")
document.form2.s3.value = "A01";
else if (document.form2.s4.value == "")
document.form2.s4.value = "A01";
else if (document.form2.s5.value == "")
document.form2.s5.value = "A01";
}
}
else if((sjedalo=="A01")&&(sjedala_selektirana[1]==1)&&(brojac>0))
{
if(sjedala_slobodna[1])
{
sjedala_selektirana[1]=0;
brojac--;
if (document.form2.s1.value == "A01")
document.form2.s1.value = "";
else if (document.form2.s2.value == "A01")
document.form2.s2.value = "";
else if (document.form2.s3.value == "A01")
document.form2.s3.value = "";
else if (document.form2.s4.value == "A01")
document.form2.s4.value = "";
else if (document.form2.s5.value == "A01")
document.form2.s5.value = "";
}
}
else if((sjedalo=="A02")&&(sjedala_selektirana[2]==0)&&(brojac<5))
{
if(sjedala_slobodna[2])
{
sjedala_selektirana[2]=1;
brojac++;
if (document.form2.s1.value == "")
document.form2.s1.value = "A02";
else if (document.form2.s2.value == "")
document.form2.s2.value = "A02";
else if (document.form2.s3.value == "")
document.form2.s3.value = "A02";
else if (document.form2.s4.value == "")
document.form2.s4.value = "A02";
else if (document.form2.s5.value == "")
document.form2.s5.value = "A02";
}
}
else if((sjedalo=="A02")&&(sjedala_selektirana[2]==1)&&(brojac>0))
{
if(sjedala_slobodna[2])
{
sjedala_selektirana[2]=0;
brojac--;
if (document.form2.s1.value == "A02")
document.form2.s1.value = "";
else if (document.form2.s2.value == "A02")
document.form2.s2.value = "";
else if (document.form2.s3.value == "A02")
document.form2.s3.value = "";
else if (document.form2.s4.value == "A02")
document.form2.s4.value = "";
else if (document.form2.s5.value == "A02")
document.form2.s5.value = "";
}
}
// it goes on until sjedalo=="A016"
// notice that each sjedalo has two 'else if's', one for
sjedala_selektirana=0 && brojac<5 and one for sjedala_selektirana=1 &&
brojac>0
and the only difference is here
// for first if
sjedala_selektirana[2]=1;
brojac++; // counter++
// for second if
sjedala_selektirana[2]=0;
brojac--; // counter--
Thank you again...