Jump to content
php.lv forumi

Could not get the display property


Dooling

Recommended Posts

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

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

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

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

×
×
  • Create New...