show block if textbox.value is ....

Status
Niet open voor verdere reacties.

johnny1963

Gebruiker
Lid geworden
23 okt 2006
Berichten
82
Hoi heb het volgende probleem hetgeen ik niet voorelkaar krijg.
Als in de textbox de value = "Rooms-Katholiek" Staat moet
de Table met id="AlsRKofJoods" zichtbaar worden. het gaat zich er dus om als de waarde met id="geloof" Rooms-Katholiek of Joods is.

De textbox waarden lees ik uit een mysql datatable. Vandaar dat ik de waarden al heb ingevuld.

HTML:
<HTML>
  <HEAD>
  <TITLE>Test</TITLE>
<script type="text/JavaScript">
function setgodsdienst(x)
{
	var godsdienst = document.getElementById('godsdienst');    
    var out = document.getElementById('geloof');	
	out.value = godsdienst.options[godsdienst.selectedIndex].value;	
	var theDropDowna = document.getElementById("godsdienst");  
	var numberOfOptionsa = theDropDowna.options.length ;
	

if(x=="Rooms-Katholiek" || x=="Joods"){
document.getElementById("AlsRKofJoods").style.display="block";
}
	 else{	 
var theDropDown = document.getElementById("provinciea");  
var numberOfOptions = theDropDown.options.length;  
	var theDropDowna = document.getElementById("gemeentena");  
	var numberOfOptionsa = theDropDowna.options.length;	
	var theDropDownb = document.getElementById("plaatsa");  
	var numberOfOptionsb = theDropDownb.options.length;	
var out = document.getElementById('continenta');
out.text = "Kies een geloof:";
out.value = "";
for (i=0; i<numberOfOptions; i++) {  
 //Note: Always remove(0) and NOT remove(i)  
 theDropDown.remove(0)  
}  
	for (i=0; i<numberOfOptionsa; i++) {  
 //Note: Always remove(0) and NOT remove(i)  
 theDropDowna.remove(0)  
}  
for (i=0; i<numberOfOptionsb; i++) {  
 //Note: Always remove(0) and NOT remove(i)  
 theDropDownb.remove(0)  
}		
	document.getElementById("AlsRKofJoods").style.display="none";	
	document.getElementById("demo2").value = '';
	document.getElementById("geboorte_landa").value = '';
	document.getElementById("geboorte_provinciea").value = '';
    document.getElementById("geboorte_gemeentea").value = '';
	document.getElementById("geboorte_plaatsa").value = '';
	document.getElementById("AlsRKofJoods").style.display="none";		
}				
}





</script>
  </HEAD>
  <BODY>
	<table>
<tr>
		<td>
		<div style="padding:7px;  width:210px; background-color:#000; color:#FFF; font-size:10px; text-align:right; float:left; ">Geloof:</div>
		<input type='text'  name='geloof' id='geloof' readonly="readonly"  value="Rooms Katholiek"  title='Hiernaast kiezen.' style="font-size:12px; height:25px; width:265px; margin-left:3px; float:left; ">
		
		<select name="godsdienst" id="godsdienst" onchange="setgodsdienst(this.value);"  title="Als niet in lijst, NIETS invullen. Keuze is niet verplicht." style="width:19em; font-size:10px;  padding:3px;  margin-left:5px; height:26px;">
		<option value=""  selected>Kies een geloof:</option>
		<option value="Moslim">Moslim</option>
		<option value="Boeddhist">Boeddhist</option>
		<option value="Rooms-Katholiek">Rooms-Katholiek</option>
		<option value="Protestants">Protestants</option>
		<option value="Joods">Joods</option>
		</select>
		</td>
		</tr>
		</table>

<table id="AlsRKofJoods" style="z-index:2; margin-top:-2px; display:none;">
		
		<tr>
		<td>
		<div style="padding:7px; height:12px; width:210px; background-color:#000; color:#FFF; font-size:10px; text-align:right; float:left;">Land gedoopt:</div>
		<input type='text' style="font-size:12px; height:25px; width:265px; margin-left:3px; float:left; " name="land_gedoopt" value="Nederland" id="geboorte_landa" title="Land gedoopt.">
		<select id="continenta" onChange="setLandena(this)" title="Je mag Land ook hiernaast zelf invullen." style="width:19em; font-size:10px;  padding:3px;  margin-left:5px; height:26px;">
		<option value="" selected="selected">Kies een Land:</option>
		<option value="Nederland">Nederland</option>
		<option value="Duitsland">Duitsland</option>
		<option value="België">België</option>
		<option value="Luxemburg">Luxemburg</option>
		<option value="USA">USA</option>
		<option value="Australië">Australië</option>
		<option value="Nieuw Zeeland">Nieuw Zeeland</option>
		</select>
		</td>
		</tr>
		<tr>
		<td>
		<div id="disp3" style="padding:7px; height:12px; width:210px; background-color:#000; color:#FFF; font-size:10px; text-align:right; float:left;">Provincie gedoopt:</div>
		<input type='text' style="font-size:12px; height:25px; width:265px; margin-left:3px; float:left; " name='provincie_gedoopt' value="Limburg" id='geboorte_provinciea' title='Provincie gedoopt.'>
		<select id="provinciea" onChange="setgemeentena(this)" title="Je mag provincie ook hiernaast zelf invullen." style="width:19em; font-size:10px; padding:3px;  margin-left:5px; height:25px;" >
		<option value=""  selected="selected"></option>
		</select>
		</td>
		</tr>
		<tr>
		<td>
		<div id="disp4" style="padding:7px; height:12px; width:210px; background-color:#000; color:#FFF; font-size:10px; text-align:right; float:left;">Gemeente gedoopt:</div>
		<input type='text' style="font-size:12px; height:25px; width:265px; margin-left:3px; float:left;" name="gemeente_gedoopt" value="Heerlen" id="geboorte_gemeentea" title="Gemeente gedoopt.">
		<select id="gemeentena" onChange="setplaatsena(this)" title="Je mag gemeente ook hiernaast zelf invullen." style="width:19em; font-size:10px; padding:3px;  margin-left:5px; height:25px;">
		<option value="" selected="selected"></option>
		</select>
		</td>
		</tr>
		<tr>
		<td>
		<div  style="padding:7px; height:12px; width:210px; background-color:#000; color:#FFF; font-size:10px; text-align:right; float:left; ">Plaats/dorp gedoopt:</div>
		<input type='text' style="font-size:12px; height:25px; width:265px;  margin-left:3px; float:left;" name="plaats_gedoopt" id="geboorte_plaatsa" value="Heksenberg" title="Geboorte plaats/dorp.">
		<select id="plaatsa" onChange="setplaatsa(this)" title="Je mag plaats/dorp ook hiernaast zelf invullen." style="width:19em; font-size:10px; padding:3px; margin-left:5px; height:25px;">
		<option value="" selected="selected"></option>
		</select>		
		</td>
		</tr>
		</table>

  </BODY>
  </HTML>
 
Laatst bewerkt:
heb het al opgelost heb onderstaande onder de table met id="AlsRKofJoods" gezet

<script type="text/JavaScript">
var textgeloof = document.getElementById('geloof').value;
if (textgeloof=="Rooms-Katholiek" || textgeloof=="Joods")
{
document.getElementById("AlsRKofJoods").style.display="block";

}


</script>
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan