petsakas
Programmer
- Nov 27, 2007
- 4
Hello all,
I have a problem submitting a form using Firefox2. I use a javascript function to update dynamically the selected value of a drop down list, based on the selection of another drop down list, which works fine. But when submitting the form that contains this drop down list, Firefox thinks it is empty and I get the message:
"Notice: Undefined index: drivernew in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\utr\action_edit_excursions_dates.php on line 59"
The same code is working in IE7.
Please help!
The form code is:
<code>
<table class="data" cellpadding="0" cellspacing="0" width="70%" id="small2">
<tr>
<th width="20%">Number</th>
<th width="15%">Plates</th>
<th width="15%">Seats</th>
<th width="25%">Driver</th>
<th width="10%">Price</th>
<th width="15%">Action<?php if($totalRows_Recordset1==0){?><a href="javascript:toggle('hiding');toggleButton('tohide2');" title="Add Line" style="float:right"><img src="icons/add_line.gif" alt="add line" width="16" height="16" title="Add Line" id="tohide2" /></a>
<?php }?></th>
</tr>
<?php $i=0;
$theSum=0;
do { $i++;
if($i<=$totalRows_Recordset1){ ?>
<tr<?php if($i%2==0){echo " class='alt'";}?>>
<td><?php echo $row_Recordset1['NUM']; ?></td>
<td><?php echo $row_Recordset1['PLATES']; ?></td>
<td><?php echo $row_Recordset1['SEATS']; ?></td>
<td><?php echo $row_Recordset1['DRIVER']; ?></td>
<td><?php $theSum=$theSum+$row_Recordset1['PRICE']; echo $row_Recordset1['PRICE']; ?>€</td>
<td><a href="action_delete_excursion_dates_bus.php?ID=<?php echo $row_Recordset1['BUSID']?>&excID=<?php echo $theID_excursions;?>" onclick="return confirm('Are you sure?');"><img src="icons/delete.gif" alt="delete" width="16" height="16" border="0" title="Delete"/></a>
<?php if($i==$totalRows_Recordset1){ ?><a href="javascript:toggle('hiding');toggleButton('tohide');"><img src="icons/add_line.gif" alt="add line" width="16" height="16" title="Add Line" id="tohide" /></a><?php } else {?> <?php }?></td>
</tr>
<?php } } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
<form id="form2" name="form2" method="POST" action="<?php echo $editFormAction; ?>">
<tr id="hiding" style="display:none;" <?php if($totalRows_Recordset1%2==1){echo " class='alt'";}?>><td><select name="busnew" style="height:20px;" onchange="updateList(<?php echo $totalRows_Recordset1; ?>,this.options[this.selectedIndex].value);">
<option value="-1" selected="selected">-- Select a bus ---</option>
<?php
for($r=0;$r<count($busses);$r++){ ?>
<option value ="<?php echo $busses[$r]['ID']; ?>" ><?php echo $busses[$r]['NUM'];?></option>
<?php } ?>
</select></td>
<td> </td><td> </td>
<td><select name="drivernew" style="height:20px;" id="drivernew">
<option value="-1" selected="selected">-- Select a driver ---</option>
<?php
for($s=0;$s<count($drivers);$s++){ ?>
<option value ="<?php echo $drivers[$s]['ID']; ?>"><?php echo $drivers[$s]['NAME'];?></option>
<?php } ?>
</select></td>
<td>€</td>
<td> <input type="image" name="submit2" value="submit" src="icons/save.gif" alt="save" width="16" height="16" /> <a href="javascript:toggle('hiding');clearLine(<?php echo $totalRows_Recordset1; ?>);<?php if($totalRows_Recordset1==0) {?>toggleButton('tohide2');<?php }else{?>toggleButton('tohide');<?php }?>"><img src="icons/cancel.gif" alt="remove line" width="16" height="16" title="Remove Line" /></a></td>
</tr>
<tr class="sum">
<td></td>
<td></td>
<td></td>
<td align="right">Total:</td>
<td><?php echo $theSum; ?>€</td>
<td></td>
</tr>
<input type="hidden" name="driverID" value="javascript:getSelectValue();" /><input type="hidden" name="MM_update" value="form2"></form>
</table>
</code>
and the javascript is:
<code>
function updateList(line,id){
var x=document.getElementById('small2').rows;
var y=x[line+1].cells;
var index=0;
for(var k=0;k<busArray.length;k++){
if(busArray[k][5]==id){
index=k;
}
}
if(id>=0){
y[1].innerHTML=busArray[index][1];
y[2].innerHTML=busArray[index][2];
y[3].innerHTML='<select name="drivernew" style="height:20px;" id="drivernew"><option value="-1">-- Select a driver ---</option><?php for($s=0;$s<count($drivers);$s++){ ?><option value ="<?php echo $drivers[$s]['ID']; ?>"><?php echo $drivers[$s]['NAME'];?></option><?php } ?></select>';
for(var l=0;l<driverArray.length;l++){
if(driverArray[l][1]==busArray[index][3]){
document.getElementById('drivernew').selectedIndex=l+1;
}
}
y[4].innerHTML=busArray[index][4]+'€';
}
else{
y[1].innerHTML='';
y[2].innerHTML='';
y[3].innerHTML='';
y[4].innerHTML='';
}
}
</code>
I have a problem submitting a form using Firefox2. I use a javascript function to update dynamically the selected value of a drop down list, based on the selection of another drop down list, which works fine. But when submitting the form that contains this drop down list, Firefox thinks it is empty and I get the message:
"Notice: Undefined index: drivernew in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\utr\action_edit_excursions_dates.php on line 59"
The same code is working in IE7.
Please help!
The form code is:
<code>
<table class="data" cellpadding="0" cellspacing="0" width="70%" id="small2">
<tr>
<th width="20%">Number</th>
<th width="15%">Plates</th>
<th width="15%">Seats</th>
<th width="25%">Driver</th>
<th width="10%">Price</th>
<th width="15%">Action<?php if($totalRows_Recordset1==0){?><a href="javascript:toggle('hiding');toggleButton('tohide2');" title="Add Line" style="float:right"><img src="icons/add_line.gif" alt="add line" width="16" height="16" title="Add Line" id="tohide2" /></a>
<?php }?></th>
</tr>
<?php $i=0;
$theSum=0;
do { $i++;
if($i<=$totalRows_Recordset1){ ?>
<tr<?php if($i%2==0){echo " class='alt'";}?>>
<td><?php echo $row_Recordset1['NUM']; ?></td>
<td><?php echo $row_Recordset1['PLATES']; ?></td>
<td><?php echo $row_Recordset1['SEATS']; ?></td>
<td><?php echo $row_Recordset1['DRIVER']; ?></td>
<td><?php $theSum=$theSum+$row_Recordset1['PRICE']; echo $row_Recordset1['PRICE']; ?>€</td>
<td><a href="action_delete_excursion_dates_bus.php?ID=<?php echo $row_Recordset1['BUSID']?>&excID=<?php echo $theID_excursions;?>" onclick="return confirm('Are you sure?');"><img src="icons/delete.gif" alt="delete" width="16" height="16" border="0" title="Delete"/></a>
<?php if($i==$totalRows_Recordset1){ ?><a href="javascript:toggle('hiding');toggleButton('tohide');"><img src="icons/add_line.gif" alt="add line" width="16" height="16" title="Add Line" id="tohide" /></a><?php } else {?> <?php }?></td>
</tr>
<?php } } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
<form id="form2" name="form2" method="POST" action="<?php echo $editFormAction; ?>">
<tr id="hiding" style="display:none;" <?php if($totalRows_Recordset1%2==1){echo " class='alt'";}?>><td><select name="busnew" style="height:20px;" onchange="updateList(<?php echo $totalRows_Recordset1; ?>,this.options[this.selectedIndex].value);">
<option value="-1" selected="selected">-- Select a bus ---</option>
<?php
for($r=0;$r<count($busses);$r++){ ?>
<option value ="<?php echo $busses[$r]['ID']; ?>" ><?php echo $busses[$r]['NUM'];?></option>
<?php } ?>
</select></td>
<td> </td><td> </td>
<td><select name="drivernew" style="height:20px;" id="drivernew">
<option value="-1" selected="selected">-- Select a driver ---</option>
<?php
for($s=0;$s<count($drivers);$s++){ ?>
<option value ="<?php echo $drivers[$s]['ID']; ?>"><?php echo $drivers[$s]['NAME'];?></option>
<?php } ?>
</select></td>
<td>€</td>
<td> <input type="image" name="submit2" value="submit" src="icons/save.gif" alt="save" width="16" height="16" /> <a href="javascript:toggle('hiding');clearLine(<?php echo $totalRows_Recordset1; ?>);<?php if($totalRows_Recordset1==0) {?>toggleButton('tohide2');<?php }else{?>toggleButton('tohide');<?php }?>"><img src="icons/cancel.gif" alt="remove line" width="16" height="16" title="Remove Line" /></a></td>
</tr>
<tr class="sum">
<td></td>
<td></td>
<td></td>
<td align="right">Total:</td>
<td><?php echo $theSum; ?>€</td>
<td></td>
</tr>
<input type="hidden" name="driverID" value="javascript:getSelectValue();" /><input type="hidden" name="MM_update" value="form2"></form>
</table>
</code>
and the javascript is:
<code>
function updateList(line,id){
var x=document.getElementById('small2').rows;
var y=x[line+1].cells;
var index=0;
for(var k=0;k<busArray.length;k++){
if(busArray[k][5]==id){
index=k;
}
}
if(id>=0){
y[1].innerHTML=busArray[index][1];
y[2].innerHTML=busArray[index][2];
y[3].innerHTML='<select name="drivernew" style="height:20px;" id="drivernew"><option value="-1">-- Select a driver ---</option><?php for($s=0;$s<count($drivers);$s++){ ?><option value ="<?php echo $drivers[$s]['ID']; ?>"><?php echo $drivers[$s]['NAME'];?></option><?php } ?></select>';
for(var l=0;l<driverArray.length;l++){
if(driverArray[l][1]==busArray[index][3]){
document.getElementById('drivernew').selectedIndex=l+1;
}
}
y[4].innerHTML=busArray[index][4]+'€';
}
else{
y[1].innerHTML='';
y[2].innerHTML='';
y[3].innerHTML='';
y[4].innerHTML='';
}
}
</code>