Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form submission problem with Firefox2

Status
Not open for further replies.

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']; ?>&#8364;</td>
<td><a href="action_delete_excursion_dates_bus.php?ID=<?php echo $row_Recordset1['BUSID']?>&amp;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>&nbsp;&nbsp;
<?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 {?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?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>&nbsp;</td><td>&nbsp;</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>&#8364;</td>
<td>&nbsp;<input type="image" name="submit2" value="submit" src="icons/save.gif" alt="save" width="16" height="16" />&nbsp;&nbsp;&nbsp;&nbsp;<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; ?>&#8364;</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]+'&#8364';
}
else{
y[1].innerHTML='';
y[2].innerHTML='';
y[3].innerHTML='';
y[4].innerHTML='';
}
}
</code>
 
I did use wrong tags didn't I? Ok, here's the HTML with the javascript, after the submission of the form

Code:
<br />
<b>Notice</b>:  Undefined index:  drivernew in <b>C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\utr\action_edit_excursions_dates.php</b> on line <b>59</b><br />
<br />
<b>Notice</b>:  Undefined index:  drivernew in <b>C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\utr\includes\validation.php</b> on line <b>304</b><br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]

<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Edit Excursion</title>
<link href="css/general_utr.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="js/show_hide_rows.js"></script>
<script language="JavaScript" src="js/toggleButton.js"></script>
<script language="javascript">

var busArray=new Array(1);
busArray[0]=new Array(6);
busArray[0][0]=33;
busArray[0][1]='HKH5578';
busArray[0][2]=80;
busArray[0][3]='Manousakas';
busArray[0][4]=569.33;
busArray[0][5]=1;

var driverArray=new Array(4);
driverArray[0]=new Array(2);
driverArray[0][0]=3;
driverArray[0][1]='Manousakas';
driverArray[1]=new Array(2);
driverArray[1][0]=4;
driverArray[1][1]='O apatosmou';
driverArray[2]=new Array(2);
driverArray[2][0]=1;
driverArray[2][1]='O Giorgis';
driverArray[3]=new Array(2);
driverArray[3][0]=2;
driverArray[3][1]='Sifomanolis';


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><option value ="3">Manousakas</option><option value ="4">O apatosmou</option><option value ="1">O Giorgis</option><option value ="2">Sifomanolis</option></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]+'&#8364';
	}
	else{
	    y[1].innerHTML='';
		y[2].innerHTML='';
		y[3].innerHTML='';
		y[4].innerHTML='';
	}
}

function clearLine(line){
	var x=document.getElementById('small2').rows;
    var y=x[line+1].cells;
	    y[1].innerHTML='';
		y[2].innerHTML='';
		y[3].innerHTML='';
  		y[4].innerHTML='';
}
</script>
</head>

<body class="section-2">

<div id="content">

<div class="table_area" style="margin-top:-1px;position:relative;">


<div id="nav">
<span class="end">&nbsp;</span>
<ul id="main_actions">
	<li><a href="view_edit_clients.php">Clients</a><span>&nbsp;</span></li>
    <li><a href="view_edit_guides.php">Guides</a><span>&nbsp;</span></li>
     <li><a href="view_edit_drivers.php">Bus Drivers</a><span>&nbsp;</span></li>
          <li><a href="view_edit_busses.php">Busses</a><span>&nbsp;</span></li>

	<li class="active"><a href="view_edit_excursions.php">Excursions</a><span>&nbsp;</span></li>
	<li><a href="view_edit_pick_up_points.php">Pick-up Points</a><span>&nbsp;</span></li>
	<li><a href="view_edit_routes.php">Routes</a><span>&nbsp;</span></li>
</ul>

</div>
<br />
<br />

  <div><table width='80%' class='data'>

  <tr><td align='center'><img src='icons/cancel.gif' height='16' width='16' /> The Driver field is mandatory</td></tr><td align='center'><img src='icons/cancel.gif' height='16' width='16' /> The Driver field is mandatory</td></tr></table></div>  
<br />
<ul id="menu">
  <li id="nav-1"><a href="view_edit_excursions.php">General Options</a></li>
  <li id="nav-2"><a href="view_edit_excursions_dates.php">Per Date Configuration</a></li>
</ul>

<div class="table_area">

<table  class="data" cellpadding="0" cellspacing="0">
<form id="form1" name="form1" method="POST" action="/utr/action_edit_excursions_dates.php?ID=1012">
  <tr>
 	<th width="20%">Excursion Name </th>
	<th width="20%">Date</th>
	<th width="10%">Places</th>
	<th width="10%">Places UTR Only</th>
	<th width="10%">Reserved Places </th>

    <th width="10%">Canceled</th>
    <th width="20%">Action</th>
   </tr>
   <tr>
      <td>Arkadi</td>
	  <td>2007-06-23</td>
	  <td>60</td>

	  <td>50</td>
	  <td></td>
	  <td><input  type="checkbox" name="checkbox" value="checkbox"/></td>
      <td><input type="image" name="submit" value="submit" src="icons/save.gif" alt="save" width="16" height="16" />&nbsp; <a href="view_edit_excursions_dates.php"><img src="icons/cancel.gif" alt="cancel" width="16" height="16" border="0" /></a></td>
</tr><input type="hidden" name="recID" value="1012" />
<input type="hidden" name="MM_update" value="form1">
</form>
</table>
</div>
<div class="table_area">
<table class="in_form" cellpadding="0" cellspacing="0" width="70%" id="small">

<tr class="head">
  <td colspan="2">Busses</td>
</tr>
</table>
  <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<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>
      </th>
</tr>
      <form id="form2" name="form2" method="POST" action="/utr/action_edit_excursions_dates.php?ID=1012">
     <tr id="hiding" style="display:none;" ><td><select name="busnew" style="height:20px;" onchange="updateList(0,this.options[this.selectedIndex].value);">
		<option value="-1" selected="selected">-- Select a bus ---</option>

		        <option value ="1" >33</option>
			   </select></td>
     <td>&nbsp;</td><td>&nbsp;</td>
	 <td><select name="drivernew" style="height:20px;" id="drivernew">
		<option value="-1" selected="selected">-- Select a driver ---</option>
		        <option value ="3">Manousakas</option>
		        <option value ="4">O apatosmou</option>

		        <option value ="1">O Giorgis</option>
		        <option value ="2">Sifomanolis</option>
			   </select></td>
	 <td>&#8364;</td>
     <td>&nbsp;<input type="image" name="submit2" value="submit" src="icons/save.gif" alt="save" width="16" height="16" />&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:toggle('hiding');clearLine(0);toggleButton('tohide2');"><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>0&#8364;</td>
    <td></td>
    </tr>
<input type="hidden" name="MM_update" value="form2"></form>
</table>
</div>

</div>
</div>
</body>
</html>
 
But what is the code before the submission? If the problem is with the data being submitted, showing us the code of the page that you get to afterwards is probably not all that helpful...

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
The code is in there. The only difference is the Notice lines before the DOCTYPE.Apart from that, it is the same. You can see the forms and the javascript.
 
Have you tried debugging the server side (e.g. printing the form submission data, etc) to see whether the values are really being posted or not?

You say that "Firefox thinks it's empty" - but does it? Try seeing what is posted. Does using IE make any difference to the posted values?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Instead of using JavaScript to insert into the page, try using JavaScript to hide/show things in the form already by toggling classes.

Inserted stuff should still be in the submission, or at least I don't see why it wouldn't...

One thing I notice is that there are two forms, whichever one is submitted is the one you'll get data for, the other won't exist on the action page.

[plug=shameless]
[/plug]
 
The form shows the field "driversnew" always empty in Firefox2, but in IE7 it has a value and the whole page works fine! That's the strange thing about the whole thing..
Yes indeed there are to forms, but the server-side code manages the checks and knows which one is submitted and for which one to look for data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top