Dooling Posted March 6, 2008 Report Share Posted March 6, 2008 Taisu divas reģistrācijas formas. Viena privātai personai, otra juridiskai personai. Kad nospiež uz radio pogas juridiska persona, tad privātas personas reģistrācijas forma pazūd un parādās juridiskās personas reģistrācijas forma un otrādi. Viss jauki strādā uz FF un Operā, bet IE, uzrāda šādu kļūdu "Could not get the display property. Invalid argument". Problēmu saprotu, ka ir vai nu block vai '', bet tāpat uz IE nedarbojas. Kā lai atrisina šo problēmu? Javascript <script type="text/javascript"> <!-- function toggleBox(szDivID, iState) // 1 visible, 0 hidden { if(document.layers) //NN4+ { document.layers[szDivID].display = iState ? 'block' : 'none'; document.layers[szDivID].display = iState ? SetCookie(szDivID) : DeleteCookie(szDivID); } else if(document.getElementById) //gecko(NN6) + IE 5+ { var obj = document.getElementById(szDivID); obj.style.display = iState ? 'block' : 'none'; obj.style.display = iState ? SetCookie(szDivID) : DeleteCookie(szDivID); } else if(document.all) // IE 4 { //alert('te 3'); document.all[szDivID].style.display = iState ? 'block' : 'none'; document.all[szDivID].style.display = iState ? SetCookie(szDivID) : DeleteCookie(szDivID); } } function Click(myName) { document.getElementById(myName).checked=true; } function Unclick(myName) { document.getElementById(myName).checked=false; } // --> </script> DIV 1 <div id="reg_field" style="display: block;"> <form style="padding:0;margin:0;border:0;" method="POST" action="login.php"> <table> <tr> <td align="right" height="26" style="vertical-align:middle;"><b>Jūsu statuss: </b></td> <td height="26" style="vertical-align:middle;"> <table style="font-size: 10px;"> <tr> <td><label for="CBBK1">Privātpersona</label></td> <td><input type="radio" name="status" ID="status1" onClick="toggleBox('reg_field',1); " VALUE="RBB1" checked></td> <td><label for="CBBK2">Juridiskā persona</label></td> <td><input type="radio" name="status" ID="status2" onClick="toggleBox('reg_field',0); toggleBox('reg_field2',1); Click('status1'); Unclick('status2');" VALUE="RBB2" ></td> </tr> </table> </td> </tr></form></div> DIV 2 <div id="reg_field2" style="display: block;"> <form style="padding:0;margin:0;border:0;" method="POST" action="login.php"> <table> <tr> <td align="right" height="26" style="vertical-align:middle;"><b>Jūsu statuss: </b></td> <td height="26" style="vertical-align:middle;"> <table style="font-size: 10px;"> <tr> <td><label for="CBBK1">Privātpersona</label></td> <td><input type="radio" name="RFRM_TP1" ID="status3" onClick="toggleBox('reg_field',1); toggleBox('reg_field2',0); Click('status4'); Unclick('status3');" VALUE="RBB1" ></td> <td><label for="CBBK2">Juridiskā persona</label></td> <td><input type="radio" name="RFRM_TP1" ID="status4" onClick="toggleBox('reg_field2',1);" VALUE="RBB2" checked></td> </tr> </table> </td> </tr></form></div> Link to comment Share on other sites More sharing options...
bubu Posted March 6, 2008 Report Share Posted March 6, 2008 Uz kuru rindu to kļūdu saka? (uzliec Microsoft Script Debugger, tas parādīs precīzu rindiņu) Kas ir SetCookie un DeleteCookie funkcijas? Link to comment Share on other sites More sharing options...
Dooling Posted March 6, 2008 Author Report Share Posted March 6, 2008 else if(document.getElementById) //gecko(NN6) + IE 5+ { var obj = document.getElementById(szDivID); obj.style.display = iState ? 'block' : 'none'; - šeit lūk ir kļūda obj.style.display = iState ? SetCookie(szDivID) : DeleteCookie(szDivID); } SetCookie un DeleteCookie funkcijas: function SetCookie(cookieName) { var date = new Date(); date.setTime(date.getTime()+(60*60*1000)); document.cookie = cookieName + "=" + cookieName + "; expires=" + date.toGMTString() + ";" + ";"; } function DeleteCookie(cookieName) { var d = new Date(); document.cookie = cookieName + "=" + cookieName + ";expires=" + d.toGMTString() + ";" + ";"; } Link to comment Share on other sites More sharing options...
Dooling Posted March 6, 2008 Author Report Share Posted March 6, 2008 Vai ieteikumi būs kā atrisināt šo problēmu? Link to comment Share on other sites More sharing options...
andrisp Posted March 6, 2008 Report Share Posted March 6, 2008 Paskaties, ko satur obj. Link to comment Share on other sites More sharing options...
Dooling Posted March 6, 2008 Author Report Share Posted March 6, 2008 Padod norādītā div'a ID Link to comment Share on other sites More sharing options...
andrisp Posted March 6, 2008 Report Share Posted March 6, 2008 Nu pag, tu skaidri zini, ka tur tiek atrasts tas elements ? Pirms tās kļūdainās rindas iemiet alert(obj); Link to comment Share on other sites More sharing options...
Dooling Posted March 6, 2008 Author Report Share Posted March 6, 2008 Respektīvi tā: FF un Opera izvada divas reizes [object HTMLDivElement], bet IE tikai vienu reizi [object] ... līdz ar to sanāk IE otrreiz nenodarbojas, jo tas nevar dabūt display atribūtu tā sanāk ? Link to comment Share on other sites More sharing options...
andrisp Posted March 6, 2008 Report Share Posted March 6, 2008 (edited) A kas otreiz parādās uz IE ? Un vispār es nesaprotu, kas te notiek: obj.style.display = iState ? SetCookie(szDivID) : DeleteCookie(szDivID); Ko tu tur mēģini izdarīt ? Edited March 6, 2008 by andrisp Link to comment Share on other sites More sharing options...
Dooling Posted March 6, 2008 Author Report Share Posted March 6, 2008 Otrreiz IE vispār neparādās. Tur tiek izveidots viens cepums un dzēsts cits cepums. Tas darbojas. Link to comment Share on other sites More sharing options...
Aleksejs Posted March 6, 2008 Report Share Posted March 6, 2008 Kas tas iState vispār ir un no kurienes rodās? Link to comment Share on other sites More sharing options...
andrisp Posted March 6, 2008 Report Share Posted March 6, 2008 (edited) Dooling, a kaapec tu to cepumu fju rezultaatu atgriez style.display propertijam ? Edited March 6, 2008 by andrisp Link to comment Share on other sites More sharing options...
Dooling Posted March 6, 2008 Author Report Share Posted March 6, 2008 Lai fiksētu izvēlēto reģistrācijas formas veidu, ja lietotājs nospiež refresh vai nejauši nospiež citu saiti. iState - 1 - div'am japarādās, 0 - div'am jāpazūd Link to comment Share on other sites More sharing options...
andrisp Posted March 6, 2008 Report Share Posted March 6, 2008 Dooling, bet kaapeec tu rezultātu (vispaar jau taas funkijas neko neatgriež) atgriez elementa stilam ? var obj = document.getElementById(szDivID); obj.style.display = iState ? 'block' : 'none'; obj.style.display = iState ? SetCookie(szDivID) : DeleteCookie(szDivID); Sanāk, ka otrajai rindiņai vispār nav jēgas, jo tu ar trešo viņu pārraksti. Link to comment Share on other sites More sharing options...
Dooling Posted March 6, 2008 Author Report Share Posted March 6, 2008 Jā, ja komentē to otro rindiņu, tad aiziet arī uz IE, bet tagad problēma kā, lai palaiž funkcijas SetCookie un DeleteCookie? Link to comment Share on other sites More sharing options...
Recommended Posts