Automatische select
thyssimonis - 25/10/2005 00:29 (laatste wijziging 25/10/2005 00:49)
PHP interesse
Hoi,
Ik kom weer met de automatische select nu nog een extra select er bij!
Ik heb het geprobeerd maar lukte niet.
Heb het volgende:
<script type="text/javascript">
<!--
function show()
{
{if(document.form1.groep.options[1].selected)
{
document.getElementById('rasHorde1').style.display = 'block';
document.getElementById('rasAlliance1').style.display = 'none';
document.getElementById('niets').style.display = 'none';
}
else
{if(document.form1.groep.options[2].selected)
{
document.getElementById('niets').style.display = 'none';
document.getElementById('rasAlliance1').style.display = 'block';
document.getElementById('rasHorde1').style.display = 'none';
}
}
}
}
-->
</script>
<?
echo '<form action="?page=leden/aanmelden" method="post" name="form1">
<table>
<tr><td>Groep</td><td><select name="groep" onchange="show()">
<option value="0">Selecteer groep</option>
<option value="1">Horde</option>
<option value="2">Alliance</option>
</select></td></tr>
<tr><td>Ras</td><td><div id="rasHorde1" style="display:none;"><select name="ras">
<option value="0">Selecteer ras</option>
<option value="1">Dwarves</option>
<option value="2">Gnomes</option>
<option value="3">Humans</option>
<option value="4">Night elves</option>
</select></div><div id="rasAlliance1" style="display:none;"><select name="ras">
<option value="0">Selecteer ras</option>
<option value="5">Orcs</option>
<option value="6">Tauren</option>
<option value="7">Trolls</option>
<option value="8">Undead</option>
</select></div>
<div id="niets" style="display:block;">
<select name="ras">
<option value="0">Selecteer ras</option>
</select></div></td></tr>
<tr><td>Class</td><td><div id="rasDwarves1" style="display:none;"><select name="class">
<option value="0">Selecteer class</option>
<option value="Paladin">Paladin</option>
<option value="Rogue">Rogue</option>
<option value="Priest">Priest</option>
<option value="Hunter">Hunter</option>
</select></div>
<div id="niets" style="display:block;">
<select name="class">
<option value="0">Selecteer class</option>
</select></div></td></tr>
</table>
</form>';
?>
<script type="text/javascript">
<!--
function show()
{
{if(document.form1.groep.options[1].selected)
{
document.getElementById('rasHorde1').style.display = 'block';
document.getElementById('rasAlliance1').style.display = 'none';
document.getElementById('niets').style.display = 'none';
}
else
{if(document.form1.groep.options[2].selected)
{
document.getElementById('niets').style.display = 'none';
document.getElementById('rasAlliance1').style.display = 'block';
document.getElementById('rasHorde1').style.display = 'none';
}
}
}
}
-->
</script>
<?
echo '<form action="?page=leden/aanmelden" method="post" name="form1"> <table>
<tr><td>Groep</td><td><select name="groep" onchange="show()">
<option value="0">Selecteer groep</option>
<option value="1">Horde</option>
<option value="2">Alliance</option>
</select></td></tr>
<tr><td>Ras</td><td><div id="rasHorde1" style="display:none;"><select name="ras">
<option value="0">Selecteer ras</option>
<option value="1">Dwarves</option>
<option value="2">Gnomes</option>
<option value="3">Humans</option>
<option value="4">Night elves</option>
</select></div><div id="rasAlliance1" style="display:none;"><select name="ras">
<option value="0">Selecteer ras</option>
<option value="5">Orcs</option>
<option value="6">Tauren</option>
<option value="7">Trolls</option>
<option value="8">Undead</option>
</select></div>
<div id="niets" style="display:block;">
<select name="ras">
<option value="0">Selecteer ras</option>
</select></div></td></tr>
<tr><td>Class</td><td><div id="rasDwarves1" style="display:none;"><select name="class">
<option value="0">Selecteer class</option>
<option value="Paladin">Paladin</option>
<option value="Rogue">Rogue</option>
<option value="Priest">Priest</option>
<option value="Hunter">Hunter</option>
</select></div>
<div id="niets" style="display:block;">
<select name="class">
<option value="0">Selecteer class</option>
</select></div></td></tr>
</table>
</form>' ;
?>
1. warrior = All Races
2. paladin Humans, Dwarves
3. rogue = Gnomes, Humans, Dwarves, Night Elves, Orcs, Undead, Trolls
4. priest = Humans, Dwarves, Night Elves, Undead, Trolls
5. mage = Humans, Gnomes, Undead, Trolls
6. warlock = Gnomes, Humans, Orcs, Undead
7. hunter = Night Elves, Dwarves, Orcs, Tauren, Trolls
8. druid = Night Elves, Tauren
9. shaman = Orcs, Tauren, Trolls
Als dus her ras Dwarvers word geselecteert moet de select Classe de juiste select pakke met daar in de classes die bij het ras horen.
als u me hier mee helpt ben ik je eewig dankbaar wat ik snap er geen *** van.
Mvg. T. Simonis
P.s. Voor de duidelijkheid er moeten dus 8 <div> bij komen.
4 antwoorden
Gesponsorde links
thyssimonis - 25/10/2005 14:54
PHP interesse
Ow. Maar dat is me probleem niet hi moet nog de juiste class select pakken.
Thomas - 26/10/2005 12:38 (laatste wijziging 26/10/2005 12:38)
Moderator
Kun je niet beter een array allowed_classes bouwen, die op grond van een race je class-div vult?
Zal vanavond eens zien.
stenno - 31/10/2005 20:20 (laatste wijziging 31/10/2005 22:16)
PHP interesse
Hier ik heb het maar even voor je gemaakt. Je moet het uiteraard zelf nog even perfectioneren en aanpassen wat je nog wil veranderen.
Maar dit is wel de bassis.
<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
<!--
var aa = Array ('1','2','3','4')
var horde = Array('Humans','Dwarves','Gnomes','Night elves');
var horde1 = Array();
horde1[0] = Array('Warrior','Paladin','Rogue','priest','mage','warlock');
horde1[1] = Array('Warrior','Paladin','Rogue','priest','hunter','');
horde1[2] = Array('Warrior','Rogue','mage','warlock','','');
horde1[3] = Array('Warrior','Rogue','priest','hunter','druid','');
var alliance = Array('Trolls','Undead','Tauren','Orcs');
var alliance1 = Array();
alliance1[0] = Array('Warrior','Rogue','priest','mage','hunter','shaman');
alliance1[1] = Array('Warrior','Rogue','priest','mage','warlock','');
alliance1[2] = Array('Warrior','hunter','druid','shaman','','');
alliance1[3] = Array('Warrior','Rogue','warlock','hunter','shaman','');
var y = horde.length;
function show ()
{
for(x=0;x<y;x++)
{
{
if (document.form1.groep.value == "1")
{
document.getElementById('option1.'+aa[x]).innerHTML = horde[x];
}
else
{
if (document.form1.groep.value == "2")
{
document.getElementById('option1.'+aa[x]).innerHTML = alliance[x];
}
}
}
}
for(x=0;x<y;x++)
{
{
if ((document.form1.ras.value == "1") && (document.form1.groep.value == "1"))
{
document.getElementById('option2.'+aa[x]).innerHTML = horde1[0][x];
}
else
{
if ((document.form1.ras.value == "2")&& (document.form1.groep.value == "1"))
{
document.getElementById('option2.'+aa[x]).innerHTML = horde1[1][x];
}
else
{
if ((document.form1.ras.value == "3")&& (document.form1.groep.value == "1"))
{
document.getElementById('option2.'+aa[x]).innerHTML = horde1[2][x];
}
else
{
if ((document.form1.ras.value == "4")&& (document.form1.groep.value == "1"))
{
document.getElementById('option2.'+aa[x]).innerHTML = horde1[3][x];
}
}
}
}
}
{
if ((document.form1.ras.value == "1")&& (document.form1.groep.value == "2"))
{
document.getElementById('option2.'+aa[x]).innerHTML = alliance1[0][x];
}
else
{
if ((document.form1.ras.value == "2")&& (document.form1.groep.value == "2"))
{
document.getElementById('option2.'+aa[x]).innerHTML = alliance1[1][x];
}
else
{
if ((document.form1.ras.value == "3")&& (document.form1.groep.value == "2"))
{
document.getElementById('option2.'+aa[x]).innerHTML = alliance1[2][x];
}
else
{
if ((document.form1.ras.value == "4")&& (document.form1.groep.value == "2"))
{
document.getElementById('option2.'+aa[x]).innerHTML = alliance1[3][x];
}
}
}
}
}
}
}
-->
</script>
</head>
<body>
<form name="form1">
<table>
<tr>
<td>Groep</td>
<td>
<select name="groep" onchange="show()">
<option value="0">Selecteer groep</option>
<option value="1">Horde</option>
<option value="2">Alliance</option>
</select>
</td>
</tr>
<tr>
<td>Ras</td><td>
<select name="ras" onchange="show()">
<option value="0">Selecteer ras</option>
<option id="option1.1" value="1"></option>
<option id="option1.2" value="2"></option>
<option id="option1.3" value="3"></option>
<option id="option1.4" value="4"></option>
</select>
</td>
</tr>
<tr>
<td>Class</td>
<td>
<select name="class">
<option value="0">Selecteer class</option>
<option id="option2.1" value="1"></option>
<option id="option2.2" value="2"></option>
<option id="option2.3" value="3"></option>
<option id="option2.4" value="4"></option>
<option id="option2.5" value="5"></option>
<option id="option2.6" value="6"></option>
</select>
</td>
</tr>
</table>
</form>
</body>
</html>
< html>
< head>
< title> Untitled</ title>
< script type= "text/javascript" >
<!--
var aa
= Array ( '1' , '2' , '3' , '4' ) var horde
= Array ( 'Humans' , 'Dwarves' , 'Gnomes' , 'Night elves' ) ;
horde1
[ 0 ] = Array ( 'Warrior' , 'Paladin' , 'Rogue' , 'priest' , 'mage' , 'warlock' ) ; horde1
[ 1 ] = Array ( 'Warrior' , 'Paladin' , 'Rogue' , 'priest' , 'hunter' , '' ) ; horde1
[ 2 ] = Array ( 'Warrior' , 'Rogue' , 'mage' , 'warlock' , '' , '' ) ; horde1
[ 3 ] = Array ( 'Warrior' , 'Rogue' , 'priest' , 'hunter' , 'druid' , '' ) ;
var alliance
= Array ( 'Trolls' , 'Undead' , 'Tauren' , 'Orcs' ) ; alliance1
[ 0 ] = Array ( 'Warrior' , 'Rogue' , 'priest' , 'mage' , 'hunter' , 'shaman' ) ; alliance1
[ 1 ] = Array ( 'Warrior' , 'Rogue' , 'priest' , 'mage' , 'warlock' , '' ) ; alliance1
[ 2 ] = Array ( 'Warrior' , 'hunter' , 'druid' , 'shaman' , '' , '' ) ; alliance1
[ 3 ] = Array ( 'Warrior' , 'Rogue' , 'warlock' , 'hunter' , 'shaman' , '' ) ;
var y = horde. length;
function show ( )
{
for ( x= 0 ; x< y; x++ )
{
{
if ( document. form1. groep. value == "1" )
{
document. getElementById( 'option1.' + aa[ x] ) . innerHTML = horde[ x] ;
}
else
{
if ( document. form1. groep. value == "2" )
{
document. getElementById( 'option1.' + aa[ x] ) . innerHTML = alliance[ x] ;
}
}
}
}
for ( x= 0 ; x< y; x++ )
{
{
if ( ( document. form1. ras. value == "1" ) && ( document. form1. groep. value == "1" ) )
{
document. getElementById( 'option2.' + aa[ x] ) . innerHTML = horde1[ 0 ] [ x] ;
}
else
{
if ( ( document. form1. ras. value == "2" ) && ( document. form1. groep. value == "1" ) )
{
document. getElementById( 'option2.' + aa[ x] ) . innerHTML = horde1[ 1 ] [ x] ;
}
else
{
if ( ( document. form1. ras. value == "3" ) && ( document. form1. groep. value == "1" ) )
{
document. getElementById( 'option2.' + aa[ x] ) . innerHTML = horde1[ 2 ] [ x] ;
}
else
{
if ( ( document. form1. ras. value == "4" ) && ( document. form1. groep. value == "1" ) )
{
document. getElementById( 'option2.' + aa[ x] ) . innerHTML = horde1[ 3 ] [ x] ;
}
}
}
}
}
{
if ( ( document. form1. ras. value == "1" ) && ( document. form1. groep. value == "2" ) )
{
document. getElementById( 'option2.' + aa[ x] ) . innerHTML = alliance1[ 0 ] [ x] ;
}
else
{
if ( ( document. form1. ras. value == "2" ) && ( document. form1. groep. value == "2" ) )
{
document. getElementById( 'option2.' + aa[ x] ) . innerHTML = alliance1[ 1 ] [ x] ;
}
else
{
if ( ( document. form1. ras. value == "3" ) && ( document. form1. groep. value == "2" ) )
{
document. getElementById( 'option2.' + aa[ x] ) . innerHTML = alliance1[ 2 ] [ x] ;
}
else
{
if ( ( document. form1. ras. value == "4" ) && ( document. form1. groep. value == "2" ) )
{
document. getElementById( 'option2.' + aa[ x] ) . innerHTML = alliance1[ 3 ] [ x] ;
}
}
}
}
}
}
}
-->
</script>
</ head>
< body>
< form name= "form1" >
< table>
< tr>
< td> Groep</ td>
< td>
< select name= "groep" onchange= "show()" >
< option value= "0" > Selecteer groep</ option>
< option value= "1" > Horde</ option>
< option value= "2" > Alliance</ option>
</ select>
</ td>
</ tr>
< tr>
< td> Ras</ td>< td>
< select name= "ras" onchange= "show()" >
< option value= "0" > Selecteer ras</ option>
< option id= "option1.1" value= "1" ></ option>
< option id= "option1.2" value= "2" ></ option>
< option id= "option1.3" value= "3" ></ option>
< option id= "option1.4" value= "4" ></ option>
</ select>
</ td>
</ tr>
< tr>
< td> Class</ td>
< td>
< select name= "class" >
< option value= "0" > Selecteer class</ option>
< option id= "option2.1" value= "1" ></ option>
< option id= "option2.2" value= "2" ></ option>
< option id= "option2.3" value= "3" ></ option>
< option id= "option2.4" value= "4" ></ option>
< option id= "option2.5" value= "5" ></ option>
< option id= "option2.6" value= "6" ></ option>
</ select>
</ td>
</ tr>
</ table>
</ form>
</ body>
</ html>
Voor vragen kan je mij altijd spreken op msn: sten_goes@Hotmail.com:p
Ps. Admins ik zou nog altijd graag de status javascript gevorderde hebben ^^
vinTage edit , al beter zo ?
Edit1) perfect !!! ^^
Gesponsorde links
Dit onderwerp is gesloten .