PHP interesse |
|
Ik heb nu dit script:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="JavaScript">
function a()
{
document.form2.result1.value=parseFloat(document.form1.sp1.value)+parseFloat(document.form1.sp2.value)+parseFloat(document.form1.sp3.value);
}
function b()
{
document.getElementById('tekst').style.display = 'block';
document.getElementById('tekst1').style.display = 'none';
}
function c()
{
{ if (parseFloat(document.form1.sp1.value)< (parseFloat(document.form1.sp2.value)+parseFloat(document.form1.sp3.value)))
{document.getElementById('tekst5').style.display = 'block'
document.getElementById('tekst7').style.display = 'block';}
}}
</script>
</head>
<div style='display:block' id='tekst1'>
<body>
<form name="form1">
<table width="600" border="3" style="border-collapse:collapse;" cellpadding="3" cellspacing="0">
<tr>
<td><input type="text" name="sp1" size="10"button value="0" ></td>
<td><input type="text" name="sp2" size="10"button value="0" ></td>
<td><input type="text" name="sp3" size="10"button value="0" ></td>
</tr>
</table>
</form>
<BUTTON type="submit" onClick="a(),b(),c()">Calculate</BUTTON>
</body>
</div>
<div style='display:none' id='tekst'>
<body>
<form name="form2">
<table>
<tr><td>resultaat 1:</td><td><div style='display:none' id='tekst5'><font size="4" color="red">Note:</font> this will be your <b>Spy rating</b> if you train <div style='display:none' id='tekst7'>
<script language="javascript">
var spies =parseFloat(document.form1.sp1.value)+parseFloat(document.form1.sp2.value)+parseFloat(document.form1.sp3.value); document.write(spies)
</script>
</div>
spies more.</div>
<input type="text" name="result1" id="txtExample" size="20" onFocus="blur()" /></td>
</table>
</form>
</body>
</div>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <script language="JavaScript"> function a() { document.form2.result1.value=parseFloat(document.form1.sp1.value)+parseFloat(document.form1.sp2.value)+parseFloat(document.form1.sp3.value); } function b() { document.getElementById('tekst').style.display = 'block'; document.getElementById('tekst1').style.display = 'none'; } function c() { { if (parseFloat(document.form1.sp1.value)< (parseFloat(document.form1.sp2.value)+parseFloat(document.form1.sp3.value))) {document.getElementById('tekst5').style.display = 'block' document.getElementById('tekst7').style.display = 'block';} }} </script> </head> <div style='display:block' id='tekst1'> <body> <form name="form1"> <table width="600" border="3" style="border-collapse:collapse;" cellpadding="3" cellspacing="0"> <tr> <td><input type="text" name="sp1" size="10"button value="0" ></td> <td><input type="text" name="sp2" size="10"button value="0" ></td> <td><input type="text" name="sp3" size="10"button value="0" ></td> </tr> </table> </form> <BUTTON type="submit" onClick="a(),b(),c()">Calculate</BUTTON> </body> </div> <div style='display:none' id='tekst'> <body> <form name="form2"> <table> <tr><td>resultaat 1:</td><td><div style='display:none' id='tekst5'><font size="4" color="red">Note:</font> this will be your <b>Spy rating</b> if you train <div style='display:none' id='tekst7'> <script language="javascript"> var spies =parseFloat(document.form1.sp1.value)+parseFloat(document.form1.sp2.value)+parseFloat(document.form1.sp3.value); document.write(spies) </script> </div> spies more.</div> <input type="text" name="result1" id="txtExample" size="20" onFocus="blur()" /></td> </table> </form> </body> </div> </html>
Die document.write () geeft nu altijd 0, omdat bij het laden van de pagina sp1,sp2 en sp3 op nul staan en dus bij elkaar op geteld 0 is. Maar ik wil dat hij de ingevoerde waarde van de variable (sp1+sp2+sp3) pas weergegeven wordt na de druk op de calculatebutton. Maar als je de document.write () dan pas uitvoerd krijg je een hele lege witte pagina met alleen de document.write () functie.
Weet iemand een goede oplossing voor dit probleem?? Of is er misschien een beter object dan document.write() om de variable weer te geven. laat het me weten.
edit: Die <div>'s werken gewoon hoor.
|