Option values
stenno - 30/07/2005 22:59 (laatste wijziging 31/07/2005 15:09)
PHP interesse
ik heb nu dit:
<head>
<script language="JavaScript">
var arr[0] // Humans
var arr[0][0] = 1;
var arr[0][1] = 1;
var arr[0][2] = 1;
var arr[0][3] = 1,3;
var arr[1] // Elves
var arr[0][0] = 1;
var arr[0][1] = 1;
var arr[0][2] = 1,3;
var arr[0][3] = 1;
var arr[2] // Dwarves
var arr[0][0] = 1;
var arr[0][1] = 1,3;
var arr[0][2] = 1;
var arr[0][3] = 1;
var arr[3] // Orcs
var arr[0][0] = 1,3;
var arr[0][1] = 1;
var arr[0][2] = 1;
var arr[0][3] = 1;
function a()
{
document.form2.result1.value = "5" * parseFloat(arr[document.form1.race.value][0]);
document.form2.result2.value = "5" * parseFloat(arr[document.form1.race.value][1]);
document.form2.result3.value = "5" * parseFloat(arr[document.form1.race.value][2]);
document.form2.result4.value = "5" * parseFloat(arr[document.form1.race.value][3]);
}
</script>
</head>
<body>
<form name="form1">
<select size="1" name="race">
<option value="0">Humans
<option value="1">Elves
<option value="2">Dwarves
<option value="3">Orcs
</select>
</form>
<BR><BR>
<form name="form2">
<input type="text" name="result1" size="20" onFocus="blur()" />
<input type="text" name="result2" size="20" onFocus="blur()" />
<input type="text" name="result3" size="20" onFocus="blur()" />
<input type="text" name="result4" size="20" onFocus="blur()" />
</form>
<BUTTON type="submit" onClick="a()">Calculate</BUTTON>
</body>
< head>
<script language = "JavaScript" >
var arr[ 0 ] // Humans
var arr[ 0 ] [ 0 ] = 1 ;
var arr[ 0 ] [ 1 ] = 1 ;
var arr[ 0 ] [ 2 ] = 1 ;
var arr[ 0 ] [ 3 ] = 1 , 3 ;
var arr[ 1 ] // Elves
var arr[ 0 ] [ 0 ] = 1 ;
var arr[ 0 ] [ 1 ] = 1 ;
var arr[ 0 ] [ 2 ] = 1 , 3 ;
var arr[ 0 ] [ 3 ] = 1 ;
var arr[ 2 ] // Dwarves
var arr[ 0 ] [ 0 ] = 1 ;
var arr[ 0 ] [ 1 ] = 1 , 3 ;
var arr[ 0 ] [ 2 ] = 1 ;
var arr[ 0 ] [ 3 ] = 1 ;
var arr[ 3 ] // Orcs
var arr[ 0 ] [ 0 ] = 1 , 3 ;
var arr[ 0 ] [ 1 ] = 1 ;
var arr[ 0 ] [ 2 ] = 1 ;
var arr[ 0 ] [ 3 ] = 1 ;
function a( )
{
document. form2. result1. value = "5" * parseFloat( arr[ document. form1. race. value] [ 0 ] ) ;
document. form2. result2. value = "5" * parseFloat( arr[ document. form1. race. value] [ 1 ] ) ;
document. form2. result3. value = "5" * parseFloat( arr[ document. form1. race. value] [ 2 ] ) ;
document. form2. result4. value = "5" * parseFloat( arr[ document. form1. race. value] [ 3 ] ) ;
}
</script>
</ head>
< body>
< form name= "form1" >
< select size= "1" name= "race" >
< option value= "0" > Humans
< option value= "1" > Elves
< option value= "2" > Dwarves
< option value= "3" > Orcs
</ select>
</ form>
< BR>< BR>
< form name= "form2" >
< input type= "text" name= "result1" size= "20" onFocus= "blur()" />
< input type= "text" name= "result2" size= "20" onFocus= "blur()" />
< input type= "text" name= "result3" size= "20" onFocus= "blur()" />
< input type= "text" name= "result4" size= "20" onFocus= "blur()" />
</ form>
< BUTTON type= "submit" onClick= "a()" > Calculate</ BUTTON>
</ body>
kan iemand me uitleggen waarrom hij het niet doet ??
14 antwoorden
Gesponsorde links
cracker - 30/07/2005 23:12 (laatste wijziging 30/07/2005 23:24)
Onbekend
Alles simpelweg samenvoegen
<select size="1" name="race">
<option value="1">1 Humans
<option value="1">1 Elves
<option value="1">1 Dwarves
<option value="1.3">1.3 Orcs
<option value="1">1 Humans
<option value="1">1 Elves
<option value="1.4">1.4 Dwarves
<option value="1">1 Orcs
<option value="1">1 Humans
<option value="1.22">1.22 Elves
<option value="1">1 Dwarves
<option value="1">1 Orcs
<option value="1.2">1.2 Humans
<option value="1">1 Elves
<option value="1">1 Dwarves
<option value="1">1 Orcs
</select>
< select size= "1" name= "race" >
< option value= "1" > 1 Humans
< option value= "1" > 1 Elves
< option value= "1" > 1 Dwarves
< option value= "1.3" > 1.3 Orcs
< option value= "1" > 1 Humans
< option value= "1" > 1 Elves
< option value= "1.4" > 1.4 Dwarves
< option value= "1" > 1 Orcs
< option value= "1" > 1 Humans
< option value= "1.22" > 1.22 Elves
< option value= "1" > 1 Dwarves
< option value= "1" > 1 Orcs
< option value= "1.2" > 1.2 Humans
< option value= "1" > 1 Elves
< option value= "1" > 1 Dwarves
< option value= "1" > 1 Orcs
</ select>
ik heb er de select-values bijgeplaatst.
stenno - 31/07/2005 09:37 (laatste wijziging 31/07/2005 11:27)
PHP interesse
Jullie begrijpen me niet goed. Ik zal de vraag anders stellen.
Ik heb 4 formules:
<head>
<script language="JavaScript">
function a()
{
document.form2.result1.value = "5" *
parseFloat(document.form1.race1.value);
document.form2.result2.value = "5" *
parseFloat(document.form1.race2.value);
document.form2.result3.value = "5" *
parseFloat(document.form1.race3.value);
document.form2.result4.value = "5" *
parseFloat(document.form1.race4.value);
}
</script>
</head>
<body>
<form name="form1">
<select size="1" name="race1">
<option value="1">Humans
<option value="1">Elves
<option value="1">Dwarves
<option value="1.3">Orcs
</select>
<select size="1" name="race2">
<option value="1">Humans
<option value="1">Elves
<option value="1.4">Dwarves
<option value="1">Orcs
</select>
<select size="1" name="race3">
<option value="1">Humans
<option value="1.22">Elves
<option value="1">Dwarves
<option value="1">Orcs
</select>
<select size="1" name="race4">
<option value="1.2">Humans
<option value="1">Elves
<option value="1">Dwarves
<option value="1">Orcs
</select>
</form>
<BR><BR>
<form name="form2">
<input type="text" name="result1" size="20" onFocus="blur()" />
<input type="text" name="result2" size="20" onFocus="blur()" />
<input type="text" name="result3" size="20" onFocus="blur()" />
<input type="text" name="result4" size="20" onFocus="blur()" />
</form>
<BUTTON type="submit" onClick="a()">Calculate</BUTTON>
</body>
< head>
<script language = "JavaScript" >
function a( )
{
document. form2. result1. value = "5" *
parseFloat( document. form1. race1. value) ;
document. form2. result2. value = "5" *
parseFloat( document. form1. race2. value) ;
document. form2. result3. value = "5" *
parseFloat( document. form1. race3. value) ;
document. form2. result4. value = "5" *
parseFloat( document. form1. race4. value) ;
}
</script>
</ head>
< body>
< form name= "form1" >
< select size= "1" name= "race1" >
< option value= "1" > Humans
< option value= "1" > Elves
< option value= "1" > Dwarves
< option value= "1.3" > Orcs
</ select>
< select size= "1" name= "race2" >
< option value= "1" > Humans
< option value= "1" > Elves
< option value= "1.4" > Dwarves
< option value= "1" > Orcs
</ select>
< select size= "1" name= "race3" >
< option value= "1" > Humans
< option value= "1.22" > Elves
< option value= "1" > Dwarves
< option value= "1" > Orcs
</ select>
< select size= "1" name= "race4" >
< option value= "1.2" > Humans
< option value= "1" > Elves
< option value= "1" > Dwarves
< option value= "1" > Orcs
</ select>
</ form>
< BR>< BR>
< form name= "form2" >
< input type= "text" name= "result1" size= "20" onFocus= "blur()" />
< input type= "text" name= "result2" size= "20" onFocus= "blur()" />
< input type= "text" name= "result3" size= "20" onFocus= "blur()" />
< input type= "text" name= "result4" size= "20" onFocus= "blur()" />
</ form>
< BUTTON type= "submit" onClick= "a()" > Calculate</ BUTTON>
</ body>
Belangrijk!!!: De gebruiker van de site vult in alle 4 de selectboxen die ik nu heb hetzelfde in dus als hij dwarves is selecteert hij in alle 4 de selectboxen dwarves.
Nu wil ik van die 4 selectboxen 1 selectbox maken met toch het zelfde resultaat. Ik heb dit geprobeerd maar dat lukte natuurlijk niet
! het ziet er ook wel zo weird uit !!
<script language="JavaScript">
function a()
{
document.form2.result1.value = "5" * parseFloat(document.form1.race1.value1);
document.form2.result2.value = "5" * parseFloat(document.form1.race1.value3);
document.form2.result3.value = "5" * parseFloat(document.form1.race1.value2);
document.form2.result4.value = "5" * parseFloat(document.form1.race1.value4);
}
</script>
</head>
<body>
<form name="form1">
<select size="1" name="race1">
<option value1="1" value2="1" value3="1" value4="1.2">Humans
<option value1="1" value2="1.22" value3="1" value4="1">Elves
<option value1="1" value2="1" value3="1.35" value4="1">Dwarves
<option value1="1.3" value2="1" value3="1" value4="1">Orcs
</select>
</form>
<BR><BR>
<form name="form2">
<input type="text" name="result1" size="20" onFocus="blur()" />
<input type="text" name="result2" size="20" onFocus="blur()" />
<input type="text" name="result3" size="20" onFocus="blur()" />
<input type="text" name="result4" size="20" onFocus="blur()" />
</form>
<BUTTON type="submit" onClick="a()">Calculate</BUTTON>
</body>
<script language = "JavaScript" >
function a( )
{
document. form2. result1. value = "5" * parseFloat( document. form1. race1. value1) ;
document. form2. result2. value = "5" * parseFloat( document. form1. race1. value3) ;
document. form2. result3. value = "5" * parseFloat( document. form1. race1. value2) ;
document. form2. result4. value = "5" * parseFloat( document. form1. race1. value4) ;
}
</script>
</ head>
< body>
< form name= "form1" >
< select size= "1" name= "race1" >
< option value1= "1" value2= "1" value3= "1" value4= "1.2" > Humans
< option value1= "1" value2= "1.22" value3= "1" value4= "1" > Elves
< option value1= "1" value2= "1" value3= "1.35" value4= "1" > Dwarves
< option value1= "1.3" value2= "1" value3= "1" value4= "1" > Orcs
</ select>
</ form>
< BR>< BR>
< form name= "form2" >
< input type= "text" name= "result1" size= "20" onFocus= "blur()" />
< input type= "text" name= "result2" size= "20" onFocus= "blur()" />
< input type= "text" name= "result3" size= "20" onFocus= "blur()" />
< input type= "text" name= "result4" size= "20" onFocus= "blur()" />
</ form>
< BUTTON type= "submit" onClick= "a()" > Calculate</ BUTTON>
</ body>
Uit dit script komt 4 keer: NAN
Simon - 31/07/2005 11:31
PHP expert
<option value1="1" value2="1" value3="1" value4="1.2">Humans
<option value1="1" value2="1.22" value3="1" value4="1">Elves
<option value1="1" value2="1" value3="1.35" value4="1">Dwarves
<option value1="1.3" value2="1" value3="1" value4="1">Orcs
< option value1= "1" value2= "1" value3= "1" value4= "1.2" > Humans
< option value1= "1" value2= "1.22" value3= "1" value4= "1" > Elves
< option value1= "1" value2= "1" value3= "1.35" value4= "1" > Dwarves
< option value1= "1.3" value2= "1" value3= "1" value4= "1" > Orcs
waarom tel je niet gewoon die values samen
Humans is dan 4.2
Elves is dan 4.22
Dwarves is 4.35
en Orcs 4.3
stenno - 31/07/2005 11:36 (laatste wijziging 31/07/2005 14:07)
PHP interesse
Omdat je dan dus hele andere waardes gebruikt in je formule.
stenno - 31/07/2005 13:55 (laatste wijziging 31/07/2005 13:59)
PHP interesse
Ok ik zal het nog een keer proberen het zo duidelijk mogelijk uit te leggen.
Ik speel online een spel. Voor dat spel maak ik nu een clansite met een calculator waarmee je dan allemaal handige dingen uit kan rekenen voor dat spel.
Hier heb je een voorbeeld:
Gebruik mijn login gegevens:
loginnaam: Stenno
password: Loet06
In dat spel kan je 4 verschillende volken zijn: Humans, Elves, Orcs, Dwarves. De rankings in dat spel worden bepaald door het gemiddelde van je:
aanvalskracht, verdedigingskracht, spionagekracht, anti-spionagekracht. (deze 4 krachten kan je berekenen met de door mij gemaakte calculator.)
Ieder volk heeft een voordeel (bonus). Bij orcs is dat bijvoorbeeld 30% extra aanvalskracht.
Dus als je de formule maakt voor aanvalskracht heb je deze selectbox nodig:
<select size="1" name="race1">
<option value="1">Humans
<option value="1">Elves
<option value="1">Dwarves
<option value="1.3">Orcs <!-- Die 1.3 is dus die 30% bonus.// -->
</select>
< select size= "1" name= "race1" >
< option value= "1" > Humans
< option value= "1" > Elves
< option value= "1" > Dwarves
< option value
= "1.3" > Orcs
<!-- Die 1.3 is dus
die 30 % bonus
. // --> </ select>
Bij dwarves is dat bijvoorbeeld 30% extra verdedigingskracht.
Dus als je de formule maakt voor verdedigingskracht heb je deze selectbox nodig:
<select size="1" name="race2">
<option value="1">Humans
<option value="1">Elves
<option value="1.3">Dwarves <!-- Die 1.3 is dus die 30% bonus.// -->
<option value="1">Orcs
</select>
< select size= "1" name= "race2" >
< option value= "1" > Humans
< option value= "1" > Elves
< option value
= "1.3" > Dwarves
<!-- Die 1.3 is dus
die 30 % bonus
. // --> < option value= "1" > Orcs
</ select>
Als je voor de formule van verdedigingskracht dezelfde selectbox zou nemen als die van aanvalskracht hebben orcs dus 30% bonus voor aanvalskracht en 30% voor verdedigingskracht.
Belangrijk:
(de door mij gemaakte calculator is voor alle volken via die selectbox moet je dus instellen welk volk je bent en dus wat je bonus is)
Voeg me toe op msn en ik zal je het hele script van de calculator geven.
msn: Sten_goes@hotmail.com
haytjes - 31/07/2005 14:16 (laatste wijziging 31/07/2005 14:16)
JS gevorderde
kan je het niet anders oplossen:
<script>
var arr[0] // Humans
var arr[0][0] = 1; // aanvalskracht
var arr[0][1] = 1; // verdedigingskracht
var arr[0][2] = 1; // spionagekracht
var arr[0][3] = 1,3; // anti-spionagekracht
var arr[1] // Elves
var arr[0][0] = 1; // aanvalskracht
var arr[0][1] = 1; // verdedigingskracht
var arr[0][2] = 1,3; // spionagekracht
var arr[0][3] = 1; // anti-spionagekracht
var arr[2] // Dwarves
var arr[0][0] = 1; // aanvalskracht
var arr[0][1] = 1,3; // verdedigingskracht
var arr[0][2] = 1; // spionagekracht
var arr[0][3] = 1; // anti-spionagekracht
var arr[3] // Orcs
var arr[0][0] = 1,3; // aanvalskracht
var arr[0][1] = 1; // verdedigingskracht
var arr[0][2] = 1; // spionagekracht
var arr[0][3] = 1; // anti-spionagekracht
function a()
{
document.form2.result1.value = "5" * parseFloat(arr[document.form1.race.value][0]);
document.form2.result2.value = "5" * parseFloat(arr[document.form1.race.value][1]);
document.form2.result3.value = "5" * parseFloat(arr[document.form1.race.value][2]);
document.form2.result4.value = "5" * parseFloat(arr[document.form1.race.value][3]);
}
</script>
<select size="1" name="race">
<option value="0">Humans
<option value="1">Elves
<option value="2">Dwarves
<option value="3">Orcs
</select>
< script>
var arr[ 0 ] // Humans
var arr[ 0 ] [ 0 ] = 1 ; // aanvalskracht
var arr[ 0 ] [ 1 ] = 1 ; // verdedigingskracht
var arr[ 0 ] [ 2 ] = 1 ; // spionagekracht
var arr[ 0 ] [ 3 ] = 1 , 3 ; // anti-spionagekracht
var arr[ 1 ] // Elves
var arr[ 0 ] [ 0 ] = 1 ; // aanvalskracht
var arr[ 0 ] [ 1 ] = 1 ; // verdedigingskracht
var arr[ 0 ] [ 2 ] = 1 , 3 ; // spionagekracht
var arr[ 0 ] [ 3 ] = 1 ; // anti-spionagekracht
var arr[ 2 ] // Dwarves
var arr[ 0 ] [ 0 ] = 1 ; // aanvalskracht
var arr[ 0 ] [ 1 ] = 1 , 3 ; // verdedigingskracht
var arr[ 0 ] [ 2 ] = 1 ; // spionagekracht
var arr[ 0 ] [ 3 ] = 1 ; // anti-spionagekracht
var arr[ 3 ] // Orcs
var arr[ 0 ] [ 0 ] = 1 , 3 ; // aanvalskracht
var arr[ 0 ] [ 1 ] = 1 ; // verdedigingskracht
var arr[ 0 ] [ 2 ] = 1 ; // spionagekracht
var arr[ 0 ] [ 3 ] = 1 ; // anti-spionagekracht
function a( )
{
document. form2. result1. value = "5" * parseFloat( arr[ document. form1. race. value] [ 0 ] ) ;
document. form2. result2. value = "5" * parseFloat( arr[ document. form1. race. value] [ 1 ] ) ;
document. form2. result3. value = "5" * parseFloat( arr[ document. form1. race. value] [ 2 ] ) ;
document. form2. result4. value = "5" * parseFloat( arr[ document. form1. race. value] [ 3 ] ) ;
}
</script>
< select size= "1" name= "race" >
< option value= "0" > Humans
< option value= "1" > Elves
< option value= "2" > Dwarves
< option value= "3" > Orcs
</ select>
stenno - 31/07/2005 14:17 (laatste wijziging 31/07/2005 14:49)
PHP interesse
Kijk zo iets bedoel ik!!! dit lijkt er op ik ga het proberen
moet de functie niet zo:
functie a ()
{
document.form2.result1.value = "5" * parseFloat(arr[0][document.form1.race.value]);
document.form2.result2.value = "5" * parseFloat(arr[1][document.form1.race.value]);
document.form2.result3.value = "5" * parseFloat(arr[2][document.form1.race.value]);
document.form2.result4.value = "5" * parseFloat(arr[3][document.form1.race.value]);
}
functie a ( )
{
document. form2. result1. value = "5" * parseFloat( arr[ 0 ] [ document. form1. race. value] ) ;
document. form2. result2. value = "5" * parseFloat( arr[ 1 ] [ document. form1. race. value] ) ;
document. form2. result3. value = "5" * parseFloat( arr[ 2 ] [ document. form1. race. value] ) ;
document. form2. result4. value = "5" * parseFloat( arr[ 3 ] [ document. form1. race. value] ) ;
}
ERROR: Wordt object verwacht bij de button.
Dit is de button:
<BUTTON type="submit" onClick="a()">Calculate</BUTTON>
< BUTTON type= "submit" onClick= "a()" > Calculate</ BUTTON>
stenno - 31/07/2005 14:56
PHP interesse
Het ziet er ook erg naar uit dat het het is maar als ik het invul in mijn htmlkit werkt het niet goed.
er komt een error: wordt object verwacht bij de button
<BUTTON type="submit" onClick="a()">Calculate</BUTTON>
< BUTTON type= "submit" onClick= "a()" > Calculate</ BUTTON>
kan je misschien even het hele script posten??
haytjes - 31/07/2005 15:24 (laatste wijziging 31/07/2005 15:29)
JS gevorderde
nu werkt het, ik heb het getest.
het grote probleem was de , -> .
<script>
var arr = Array();
arr[0] = Array('1','1','1','1.3'); // Humans
arr[1] = Array('1','1','1.3','1'); // Elves
arr[2] = Array('1','1.3','1','1'); // Dwarves
arr[3] = Array('1.3','1','1','1'); // Orcs
function a()
{
document.form2.result1.value = "5" * parseFloat(arr[document.form1.race.value][0]);
document.form2.result2.value = "5" * parseFloat(arr[document.form1.race.value][1]);
document.form2.result3.value = "5" * parseFloat(arr[document.form1.race.value][2]);
document.form2.result4.value = "5" * parseFloat(arr[document.form1.race.value][3]);
}
</script>
<form name="form1" onclick='a()'>
<select size="1" name="race">
<option value="0">Humans
<option value="1">Elves
<option value="2">Dwarves
<option value="3">Orcs
</select>
</form>
<form name="form2">
<input type="text" name="result1" size="20" onFocus="blur()" />
<input type="text" name="result2" size="20" onFocus="blur()" />
<input type="text" name="result3" size="20" onFocus="blur()" />
<input type="text" name="result4" size="20" onFocus="blur()" />
</form>
< script>
arr
[ 0 ] = Array ( '1' , '1' , '1' , '1.3' ) ; // Humans arr
[ 1 ] = Array ( '1' , '1' , '1.3' , '1' ) ; // Elves arr
[ 2 ] = Array ( '1' , '1.3' , '1' , '1' ) ; // Dwarves arr
[ 3 ] = Array ( '1.3' , '1' , '1' , '1' ) ; // Orcs
function a( )
{
document. form2. result1. value = "5" * parseFloat( arr[ document. form1. race. value] [ 0 ] ) ;
document. form2. result2. value = "5" * parseFloat( arr[ document. form1. race. value] [ 1 ] ) ;
document. form2. result3. value = "5" * parseFloat( arr[ document. form1. race. value] [ 2 ] ) ;
document. form2. result4. value = "5" * parseFloat( arr[ document. form1. race. value] [ 3 ] ) ;
}
</script>
< form name= "form1" onclick= 'a()' >
< select size= "1" name= "race" >
< option value= "0" > Humans
< option value= "1" > Elves
< option value= "2" > Dwarves
< option value= "3" > Orcs
</ select>
</ form>
< form name= "form2" >
< input type= "text" name= "result1" size= "20" onFocus= "blur()" />
< input type= "text" name= "result2" size= "20" onFocus= "blur()" />
< input type= "text" name= "result3" size= "20" onFocus= "blur()" />
< input type= "text" name= "result4" size= "20" onFocus= "blur()" />
</ form>
[edit]
document.title = document.form1.race.value; weggedaan
stenno - 31/07/2005 20:01
PHP interesse
Ok hij doet het echt super bedankt man !!! ik ben hier echt al 5 dagen mee bezig om het goed uit te leggen aan iedereen maar niemand begreep me !!! echt heel bedankt !!
Mag gesloten
Gesponsorde links
Dit onderwerp is gesloten .