speedy_rudolf
01 Oct 2009, 01:35 PM
Hi. I'm trying to make a web site with javascript validation...But I kind of hit a bump...
<html>
<head>
<script language="javascript">
<!--
function Val_bn_c(){
if(document.site.Bn_c_pr_n[1].checked){
document.site.Bn_c_p_n.style.display=""}
else{
document.site.Bn_c_p_n.style.display="none"}
if(document.site.Bn_c_sec_n[1].checked){
document.site.Bn_c_s_n.style.display=""}
else{
document.site.Bn_c_s_n.style.display="none"}
if(document.site.Bn_c_pr_mo[1].checked){
document.site.Bn_c_p_mo.style.display=""}
else{
document.site.Bn_c_p_mo.style.display="none"}
if(document.site.Bn_c_sec_mo[1].checked){
document.site.Bn_c_s_n.style.display=""}
else{
document.site.Bn_c_s_mo.style.display="none"}
if(document.site.Bn_c_pr_md[1].checked){
document.site.Bn_c_p_md.style.display=""}
else{
document.site.Bn_c_p_md.style.display="none"}
if(document.site.Bn_c_sec_md[1].checked){
document.site.Bn_c_s_md.style.display=""}
else{
document.site.Bn_c_s_md.style.display="none"}
if(document.site.Bn_font[1].checked){
document.getElementById('Bn_f_t_t').style.display=""
document.getElementById('Bn_f_t_t').style.display="none"}
else{
if(document.site.Bn_font[2].checked){
document.getElementById('Bn_f_t_t').style.display="none"
document.getElementById('Bn_f_t_t').style.display=""}
else{
document.getElementById('Bn_f_t_t').style.display="none"
document.getElementById('Bn_f_t_t').style.display="none"}}
if(document.site.Bn_f_c[1].checked){
document.site.Bn_f_c_t.style.display=""}
else{
document.site.Bn_f_c_t.style.display="none"}}
function Cont_pag_5_3_5(){
var a1=0, a2=0, b1=0, b2=0, c1=0, c2=0, d1=0, d2=0
if(document.site.Bn_c_pr_n[0].checked){
a1=1}
else{
if(document.site.Bn_c_pr_n[1].checked){
if(document.site.Bn_c_p_n.value.length>2){
a1=1}
else{
a1=0}}
else{
a1=0}}
if(document.site.Bn_c_sec_n[0].checked){
a2=1}
else{
if(document.site.Bn_c_sec_n[1].checked){
if(document.site.Bn_c_s_n.value.length>2){
a2=1}
else{
a2=0}}
else{
a2=0}}
if(document.site.Bn_c_pr_mo[0].checked){
b1=1}
else{
if(document.site.Bn_c_pr_mo[1].checked){
if(document.site.Bn_c_p_mo.value.length>2){
b1=1}
else{
b1=0}}
else{
b1=0}}
if(document.site.Bn_c_sec_mo[0].checked){
b2=1}
else{
if(document.site.Bn_c_sec_mo[1].checked){
if(document.site.Bn_c_s_mo.value.length>2){
b2=1}
else{
b2=0}}
else{
b2=0}}
if(document.site.Bn_c_pr_md[0].checked){
c1=1}
else{
if(document.site.Bn_c_pr_md[1].checked){
if(document.site.Bn_c_p_md.value.length>2){
c1=1}
else{
c1=0}}
else{
c1=0}}
if(document.site.Bn_c_sec_md[0].checked){
c2=1}
else{
if(document.site.Bn_c_sec_md[1].checked){
if(document.site.Bn_c_s_md.value.length>2){
c2=1}
else{
c2=0}}
else{
c2=0}}
if(document.site.Bn_font[0].checked){
d1=1}
else{
if(document.site.Bn_font[1].checked){
if(document.site.Bn_f_t_t.value.length>2){
d1=1}
else{
d1=0}}
else{
if(document.site.Bn_font[2].checked){
if(document.site.Bn_f_t_f.value!=""){
d1=1}
else{
d1=0}}
else{
d1=0}}}
if(document.site.Bn_f_c[0].checked){
d2=1}
else{
if(document.site.Bn_f_c[1].checked){
if(document.site.Bn_f_c_t.value.length>2){
d2=1}
else{
d2=0}}
else{
d2=0}}
if(a1==1 && a2==1 && b1==1 && b2==1 && c1==1 && c2==1 && d1==1 && d2==1){
document.site.pag6_2.disabled=false}
else{
document.site.pag6_2.disabled=true}}
// -->
</script>
</head>
<body>
<form method="post" name="site" action="site.php" enctype="multipart/form-data">
<div id="pagina5_3_5" class="comanda">
Pasul V: Bara de navigare III<br/><br/>
1) Culoarea principala-normal<br/>
Puteti scrie numele culorii (ex: albastru, azur etc) sau codul (ex: 0000DF, 33FFFF).<br/>
<input type="radio" name="Bn_c_pr_n" value="Same" onClick="Val_bn_c();Cont_pag5_3_5()">Pastreaza culoarea originala / Nu exista<br/>
<input type="radio" name="Bn_c_pr_n" value="Select" onClick="Val_bn_c();Cont_pag5_3_5()">Scrie culoarea<br/>
<input type="text" name="Bn_c_p_n" size="80" style="display: none" onKeyUp="Cont_pag5_3_5()"><br/><br/>
2) Culoarea secundara-normal (daca exista)<br/>
<input type="radio" name="Bn_c_sec_n" value="Same" onClick="Val_bn_c();Cont_pag5_3_5()">Pastreaza culoarea originala / Nu exista<br/>
<input type="radio" name="Bn_c_sec_n" value="Select" onClick="Val_bn_c();Cont_pag5_3_5()">Scrie culoarea<br/>
<input type="text" name="Bn_c_s_n" size="80" style="display: none" onKeyUp="Cont_pag5_3_5()"><br/><br/>
3) Culoarea principala-mouse deasupra<br/>
<input type="radio" name="Bn_c_pr_mo" value="Same" onClick="Val_bn_c();Cont_pag5_3_5()">Pastreaza culoarea originala / Nu exista<br/>
<input type="radio" name="Bn_c_pr_mo" value="Select" onClick="Val_bn_c();Cont_pag5_3_5()">Scrie culoarea<br/>
<input type="text" name="Bn_c_p_mo" size="80" style="display: none" onKeyUp="Cont_pag5_3_5()"><br/><br/>
4) Culoarea secundara-mouse deasupra (daca exista)<br/>
<input type="radio" name="Bn_c_sec_mo" value="Same" onClick="Val_bn_c();Cont_pag5_3_5()">Pastreaza culoarea originala / Nu exista<br/>
<input type="radio" name="Bn_c_sec_mo" value="Select" onClick="Val_bn_c();Cont_pag5_3_5()">Scrie culoarea<br/>
<input type="text" name="Bn_c_s_mo" size="80" style="display: none" onKeyUp="Cont_pag5_3_5()"><br/><br/>
5) Culoarea principala-mouse apasat<br/>
Puteti scrie numele culorii (ex: albastru, azur etc) sau codul (ex: 0000DF, 33FFFF).<br/>
<input type="radio" name="Bn_c_pr_md" value="Same" onClick="Val_bn_c();Cont_pag5_3_5()">Pastreaza culoarea originala / Nu exista<br/>
<input type="radio" name="Bn_c_pr_md" value="Select" onClick="Val_bn_c();Cont_pag5_3_5()">Scrie culoarea<br/>
<input type="text" name="Bn_c_p_md" size="80" style="display: none" onKeyUp="Cont_pag5_3_5()"><br/><br/>
6) Culoarea secundara-mouse apasat (daca exista)<br/>
<input type="radio" name="Bn_c_sec_md" value="Same" onClick="Val_bn_c();Cont_pag5_3_5()">Pastreaza culoarea originala / Nu exista<br/>
<input type="radio" name="Bn_c_sec_md" value="Select" onClick="Val_bn_c();Cont_pag5_3_5()">Scrie culoarea<br/>
<input type="text" name="Bn_c_s_md" size="80" style="display: none" onKeyUp="Cont_pag5_3_5()"><br/><br/>
7) Font-ul<br/>
Puteti scrie numele fontului sau linkul unde il putem gasi sau sa ne trimiteti un font personalizat.<br/>
<input type="radio" name="Bn_font" value="Same" onClick="Val_bn_c();Cont_pag5_3_5()">Pastreaza fontul original<br/>
<input type="radio" name="Bn_font" value="Text" onClick="Val_bn_c();Cont_pag5_3_5()">Scrie numele/link-ul font-ului<br/>
<table id="Bn_f_t_t" style="display: none"><tr><td><input type="text" name="Bn_f_t" size="80" onKeyUp="Cont_pag5_3_5()"></td></tr></table>
<input type="radio" name="Bn_font" value="Fisier" onClick="Val_b_c();Cont_pag5_3_5()">Trimite font-ul<br/>
<table id="Bn_f_t_f" style="display: none"><tr><td><input type="file" name="Bn_f_f" size="100" onChange="Cont_pag5_3_5()"></td></tr></table><br/>
8) Culoarea font-ului<br/>
<input type="radio" name="Bn_f_c" value="Same" onClick="Val_bn_c();Cont_pag5_3_5()">Pastreaza culoarea originala<br/>
<input type="radio" name="Bn_f_c" value="Select" onClick="Val_bn_c();Cont_pag5_3_5()">Scrie culoarea<br/>
<input type="text" name="Bn_f_c_t" size="80" style="display: none" onKeyUp="Cont_pag5_3_5()"><br/><br/>
9) Observatii<br/>
Daca aveti observatii/idei legate de banner, le puteti scrie aici.<br/>
Nu este un camp obligatoriu.<br/>
<textarea name="Obs_bn" cols="80" rows="7"></textarea><br/><br/><br/><br/>
<input type="button" name="pag4_1" value="Pagina precedenta">    
<input type="button" name="pag6_2" value="Continua comanda" disabled=true>
</div>
<p><input type="submit" name="submit" value="Finalizeaza">
</form>
</body>
</html>
Sorry for posting so much code...but this is just a very small part of the site :D
Anyway...IE8 sais "object expected", Firefox sais "Cont_pag5_3_5 is not defined"...
Can anyone tell me what's wrong with the code? Thank you. Bye.
<html>
<head>
<script language="javascript">
<!--
function Val_bn_c(){
if(document.site.Bn_c_pr_n[1].checked){
document.site.Bn_c_p_n.style.display=""}
else{
document.site.Bn_c_p_n.style.display="none"}
if(document.site.Bn_c_sec_n[1].checked){
document.site.Bn_c_s_n.style.display=""}
else{
document.site.Bn_c_s_n.style.display="none"}
if(document.site.Bn_c_pr_mo[1].checked){
document.site.Bn_c_p_mo.style.display=""}
else{
document.site.Bn_c_p_mo.style.display="none"}
if(document.site.Bn_c_sec_mo[1].checked){
document.site.Bn_c_s_n.style.display=""}
else{
document.site.Bn_c_s_mo.style.display="none"}
if(document.site.Bn_c_pr_md[1].checked){
document.site.Bn_c_p_md.style.display=""}
else{
document.site.Bn_c_p_md.style.display="none"}
if(document.site.Bn_c_sec_md[1].checked){
document.site.Bn_c_s_md.style.display=""}
else{
document.site.Bn_c_s_md.style.display="none"}
if(document.site.Bn_font[1].checked){
document.getElementById('Bn_f_t_t').style.display=""
document.getElementById('Bn_f_t_t').style.display="none"}
else{
if(document.site.Bn_font[2].checked){
document.getElementById('Bn_f_t_t').style.display="none"
document.getElementById('Bn_f_t_t').style.display=""}
else{
document.getElementById('Bn_f_t_t').style.display="none"
document.getElementById('Bn_f_t_t').style.display="none"}}
if(document.site.Bn_f_c[1].checked){
document.site.Bn_f_c_t.style.display=""}
else{
document.site.Bn_f_c_t.style.display="none"}}
function Cont_pag_5_3_5(){
var a1=0, a2=0, b1=0, b2=0, c1=0, c2=0, d1=0, d2=0
if(document.site.Bn_c_pr_n[0].checked){
a1=1}
else{
if(document.site.Bn_c_pr_n[1].checked){
if(document.site.Bn_c_p_n.value.length>2){
a1=1}
else{
a1=0}}
else{
a1=0}}
if(document.site.Bn_c_sec_n[0].checked){
a2=1}
else{
if(document.site.Bn_c_sec_n[1].checked){
if(document.site.Bn_c_s_n.value.length>2){
a2=1}
else{
a2=0}}
else{
a2=0}}
if(document.site.Bn_c_pr_mo[0].checked){
b1=1}
else{
if(document.site.Bn_c_pr_mo[1].checked){
if(document.site.Bn_c_p_mo.value.length>2){
b1=1}
else{
b1=0}}
else{
b1=0}}
if(document.site.Bn_c_sec_mo[0].checked){
b2=1}
else{
if(document.site.Bn_c_sec_mo[1].checked){
if(document.site.Bn_c_s_mo.value.length>2){
b2=1}
else{
b2=0}}
else{
b2=0}}
if(document.site.Bn_c_pr_md[0].checked){
c1=1}
else{
if(document.site.Bn_c_pr_md[1].checked){
if(document.site.Bn_c_p_md.value.length>2){
c1=1}
else{
c1=0}}
else{
c1=0}}
if(document.site.Bn_c_sec_md[0].checked){
c2=1}
else{
if(document.site.Bn_c_sec_md[1].checked){
if(document.site.Bn_c_s_md.value.length>2){
c2=1}
else{
c2=0}}
else{
c2=0}}
if(document.site.Bn_font[0].checked){
d1=1}
else{
if(document.site.Bn_font[1].checked){
if(document.site.Bn_f_t_t.value.length>2){
d1=1}
else{
d1=0}}
else{
if(document.site.Bn_font[2].checked){
if(document.site.Bn_f_t_f.value!=""){
d1=1}
else{
d1=0}}
else{
d1=0}}}
if(document.site.Bn_f_c[0].checked){
d2=1}
else{
if(document.site.Bn_f_c[1].checked){
if(document.site.Bn_f_c_t.value.length>2){
d2=1}
else{
d2=0}}
else{
d2=0}}
if(a1==1 && a2==1 && b1==1 && b2==1 && c1==1 && c2==1 && d1==1 && d2==1){
document.site.pag6_2.disabled=false}
else{
document.site.pag6_2.disabled=true}}
// -->
</script>
</head>
<body>
<form method="post" name="site" action="site.php" enctype="multipart/form-data">
<div id="pagina5_3_5" class="comanda">
Pasul V: Bara de navigare III<br/><br/>
1) Culoarea principala-normal<br/>
Puteti scrie numele culorii (ex: albastru, azur etc) sau codul (ex: 0000DF, 33FFFF).<br/>
<input type="radio" name="Bn_c_pr_n" value="Same" onClick="Val_bn_c();Cont_pag5_3_5()">Pastreaza culoarea originala / Nu exista<br/>
<input type="radio" name="Bn_c_pr_n" value="Select" onClick="Val_bn_c();Cont_pag5_3_5()">Scrie culoarea<br/>
<input type="text" name="Bn_c_p_n" size="80" style="display: none" onKeyUp="Cont_pag5_3_5()"><br/><br/>
2) Culoarea secundara-normal (daca exista)<br/>
<input type="radio" name="Bn_c_sec_n" value="Same" onClick="Val_bn_c();Cont_pag5_3_5()">Pastreaza culoarea originala / Nu exista<br/>
<input type="radio" name="Bn_c_sec_n" value="Select" onClick="Val_bn_c();Cont_pag5_3_5()">Scrie culoarea<br/>
<input type="text" name="Bn_c_s_n" size="80" style="display: none" onKeyUp="Cont_pag5_3_5()"><br/><br/>
3) Culoarea principala-mouse deasupra<br/>
<input type="radio" name="Bn_c_pr_mo" value="Same" onClick="Val_bn_c();Cont_pag5_3_5()">Pastreaza culoarea originala / Nu exista<br/>
<input type="radio" name="Bn_c_pr_mo" value="Select" onClick="Val_bn_c();Cont_pag5_3_5()">Scrie culoarea<br/>
<input type="text" name="Bn_c_p_mo" size="80" style="display: none" onKeyUp="Cont_pag5_3_5()"><br/><br/>
4) Culoarea secundara-mouse deasupra (daca exista)<br/>
<input type="radio" name="Bn_c_sec_mo" value="Same" onClick="Val_bn_c();Cont_pag5_3_5()">Pastreaza culoarea originala / Nu exista<br/>
<input type="radio" name="Bn_c_sec_mo" value="Select" onClick="Val_bn_c();Cont_pag5_3_5()">Scrie culoarea<br/>
<input type="text" name="Bn_c_s_mo" size="80" style="display: none" onKeyUp="Cont_pag5_3_5()"><br/><br/>
5) Culoarea principala-mouse apasat<br/>
Puteti scrie numele culorii (ex: albastru, azur etc) sau codul (ex: 0000DF, 33FFFF).<br/>
<input type="radio" name="Bn_c_pr_md" value="Same" onClick="Val_bn_c();Cont_pag5_3_5()">Pastreaza culoarea originala / Nu exista<br/>
<input type="radio" name="Bn_c_pr_md" value="Select" onClick="Val_bn_c();Cont_pag5_3_5()">Scrie culoarea<br/>
<input type="text" name="Bn_c_p_md" size="80" style="display: none" onKeyUp="Cont_pag5_3_5()"><br/><br/>
6) Culoarea secundara-mouse apasat (daca exista)<br/>
<input type="radio" name="Bn_c_sec_md" value="Same" onClick="Val_bn_c();Cont_pag5_3_5()">Pastreaza culoarea originala / Nu exista<br/>
<input type="radio" name="Bn_c_sec_md" value="Select" onClick="Val_bn_c();Cont_pag5_3_5()">Scrie culoarea<br/>
<input type="text" name="Bn_c_s_md" size="80" style="display: none" onKeyUp="Cont_pag5_3_5()"><br/><br/>
7) Font-ul<br/>
Puteti scrie numele fontului sau linkul unde il putem gasi sau sa ne trimiteti un font personalizat.<br/>
<input type="radio" name="Bn_font" value="Same" onClick="Val_bn_c();Cont_pag5_3_5()">Pastreaza fontul original<br/>
<input type="radio" name="Bn_font" value="Text" onClick="Val_bn_c();Cont_pag5_3_5()">Scrie numele/link-ul font-ului<br/>
<table id="Bn_f_t_t" style="display: none"><tr><td><input type="text" name="Bn_f_t" size="80" onKeyUp="Cont_pag5_3_5()"></td></tr></table>
<input type="radio" name="Bn_font" value="Fisier" onClick="Val_b_c();Cont_pag5_3_5()">Trimite font-ul<br/>
<table id="Bn_f_t_f" style="display: none"><tr><td><input type="file" name="Bn_f_f" size="100" onChange="Cont_pag5_3_5()"></td></tr></table><br/>
8) Culoarea font-ului<br/>
<input type="radio" name="Bn_f_c" value="Same" onClick="Val_bn_c();Cont_pag5_3_5()">Pastreaza culoarea originala<br/>
<input type="radio" name="Bn_f_c" value="Select" onClick="Val_bn_c();Cont_pag5_3_5()">Scrie culoarea<br/>
<input type="text" name="Bn_f_c_t" size="80" style="display: none" onKeyUp="Cont_pag5_3_5()"><br/><br/>
9) Observatii<br/>
Daca aveti observatii/idei legate de banner, le puteti scrie aici.<br/>
Nu este un camp obligatoriu.<br/>
<textarea name="Obs_bn" cols="80" rows="7"></textarea><br/><br/><br/><br/>
<input type="button" name="pag4_1" value="Pagina precedenta">    
<input type="button" name="pag6_2" value="Continua comanda" disabled=true>
</div>
<p><input type="submit" name="submit" value="Finalizeaza">
</form>
</body>
</html>
Sorry for posting so much code...but this is just a very small part of the site :D
Anyway...IE8 sais "object expected", Firefox sais "Cont_pag5_3_5 is not defined"...
Can anyone tell me what's wrong with the code? Thank you. Bye.