Donotalo
July 16th, 2007, 07:57 AM
I've a table defined like this:
<table width="100%" border="4" rules="none" bordercolor="darkblue">
<tr>
<td><input type="button" name="rolldicebutton" width="25%"
value="Roll dice (3)" onclick="roll_dice_clicked()" /></td>
<?php
for ($i = 0; $i < 5; $i++)
print "<td align='center' width='15%' name = 'dice_here'>0</td>";
?>
</tr>
</table>
so there are 5 table cells named dice_here. on the onClick event of the button, i want to change the value inside this table cells.
function roll_dice_clicked() {
var dice_here_data = document.getElementsByName("dice_here");
for (i = 0; i < dice_here_data.length; i++) {
//action here
}
}
how can i do this? please help.
i cannot use id attribute because on the server side i'm using php. when php gets some value by POST methode, it cannot recognize id's, though it can recognize name's.
another weird thing is that, inside roll_dice_clicked() function, the dice_here_data.length is 5 only in firefox (2.0.0.4), but it is 0 in opera 9.21 and IE 6. i tried it by window.alert(dice_here_data.length). why?
thanks in advance
<table width="100%" border="4" rules="none" bordercolor="darkblue">
<tr>
<td><input type="button" name="rolldicebutton" width="25%"
value="Roll dice (3)" onclick="roll_dice_clicked()" /></td>
<?php
for ($i = 0; $i < 5; $i++)
print "<td align='center' width='15%' name = 'dice_here'>0</td>";
?>
</tr>
</table>
so there are 5 table cells named dice_here. on the onClick event of the button, i want to change the value inside this table cells.
function roll_dice_clicked() {
var dice_here_data = document.getElementsByName("dice_here");
for (i = 0; i < dice_here_data.length; i++) {
//action here
}
}
how can i do this? please help.
i cannot use id attribute because on the server side i'm using php. when php gets some value by POST methode, it cannot recognize id's, though it can recognize name's.
another weird thing is that, inside roll_dice_clicked() function, the dice_here_data.length is 5 only in firefox (2.0.0.4), but it is 0 in opera 9.21 and IE 6. i tried it by window.alert(dice_here_data.length). why?
thanks in advance