Help -> JS probleem, denk ik.

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Rens Rikkerink

Rens Rikkerink

30/01/2008 08:53:00
Quote Anchor link
Hallo,
Ik heb hier een teken-scriptje gebaseerd op javascript, maar het onClick gedeelte werkt niet. Hier is mijn code:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php

//DrawIt!!! Online Painting System
//Copyright Walotech 2007


$mode = $_GET['mode'];

If ( $mode == null )
{

   If ( !$_GET['loaded'] )
   {

      header('Location: index.php?mode=load');
      exit;
   }

   $fx = 62;
   $fy = 21;
   $flds = $fx * $fy;
   ?>
<script language=javascript>
function over(numb) {
if ( document.options.mode.value == 'over' )
   {
   COLO = document.options.color.value;
   <?php
For ( $nowe = 1; $nowe < $flds; $nowe++ )
{

   ?>
   if ( numb == <?php echo $nowe; ?> )
        {
        document.img<?php echo $nowe; ?>.src = './fields/'+COLO+'.bmp';
        }
   <?php
}
?>

}
}

function click(numb) {
if ( document.options.mode.value == 'clic' )
   {
   COLO = document.options.color.value;
   <?php
For ( $nowe = 1; $nowe < $flds; $nowe++ )
{

   ?>
   if ( numb == <?php echo $nowe; ?> )
        {
        document.img<?php echo $nowe; ?>.src = './fields/'+COLO+'.bmp';
        }
   <?php
}
?>

}
}
</script>
<font size="15" color="red">Draw It!!!</font>
<br><br>Welcome to this online painting system...<br>
You can draw your own images here online!!!
<form name="options">
Color: <select name="color">
black.blue.brown.green.red.white.yellow
<option value="black">Black</option>
<option value="blue" style="color:blue">Blue</option>
<option value="brown" style="color:brown">Brown</option>
<option value="green" style="color:green">Green</option>
<option value="red" style="color:red">Red</option>
<option value="white">White</option>
<option value="yellow" style="color:yellow">Yellow</option>
</select><br>
Mode: <select name="mode">
<option value="over">On mouse over</option>
<option value="clic">On click</option>
</select><br>
<br><br>
</form><div style="border:1px dashed gray"><?php
   $this
= 1;
   For ( $curr == 1; $curr < $flds; $curr++ )
   {

      If ( $curr == null )
      {

         $curr = 1;
      }

      If ( $this == $fx )
      {

         echo '<br>';
         $this = 1;
      }

      $this++;
      echo '<A onMouseOver="javascript:over('.$curr.');" onClick="javascript:click('.$curr.');"><img onClick="javascript:click('.$curr.')" src="./fields/white.bmp" border="0" name="img'.$curr.'"></A>';
   }

   echo '</div>';
}

Else If ( $mode == 'load' )
{

   ?>
<body onload="window.location = 'index.php?loaded=1';">
Loading... Please wait...<br>
<img src="./fields/brown.bmp">
<img src="./fields/black.bmp">
<img src="./fields/blue.bmp">
<img src="./fields/green.bmp">
<img src="./fields/red.bmp">
<img src="./fields/yellow.bmp">
<img src="./fields/white.bmp">
</body><?php
}

?>
Gewijzigd op 01/01/1970 01:00:00 door Rens Rikkerink
 
PHP hulp

PHP hulp

26/04/2024 04:16:29
 
Jacco Engel

Jacco Engel

30/01/2008 09:21:00
Quote Anchor link
Zou zeggen ga het debuggen met firefox+firebug
 
Jan Koehoorn

Jan Koehoorn

30/01/2008 09:28:00
Quote Anchor link
Je vraagt de waarde van die select verkeerd op. Beter zo:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
<?php
    window.onload = init;
    
    function
init () {
        // hier aan de gang met:
        if (document.getElementById ('color').value == 'over') {
            // doe iets
        }
    }

?>
 
Rens Rikkerink

Rens Rikkerink

05/02/2008 15:12:00
Quote Anchor link
Kun je dat even uitleggen?
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.