Jump to content

Form in function that is repeated, not working


Mutley

Recommended Posts

I have a function it contains the following form:

 

*snip*

<div>
<div style="float:left">
<form enctype="multipart/form-data" action="loadout2.php" method="post">
<input type="hidden" name="goprodid" value="<?=$prod_id?>" />
<input type="hidden" name="goownid" value="<?=$own_id?>" />
<input type="hidden" name="gochkmarket" value="<?=$market_id?>" />
<select name="partoptions" style="width:50px">
	<option name="select" value="0" selected="selected"> </option>
	<option name="gorepair" value="1" <? if($stock=='0'){?>disabled="disabled"<? }else{ echo"";}?>>Repair (-£<?=round($y)?>)</option>
	<option name="goreplace" value="2" <? if($stock=='0'){?>disabled="disabled"<? }else{ echo"";}?>>Replace (-£<?=round($price)?>)</option>
	<option name="gobin" value="3">Bin (+£3)</option>
	<option name="gomarket" value="4" <? if($loadout=='1'){?>disabled="disabled"<? }else{ echo"";}?>><? if($market_id == '1'){ echo "Remove off Market"; }else{ echo "Sell on Market";}?></option>
</select>
</div>
<div>
<input type="submit" name="gosubmit" value="Go!" style="width:30px; font-size:xx-small" />
	<?
		if($market_id == '1') {
			echo " <img src=\"images/restrict_market.png\" style=\"vertical-align:top\" alt=\"On Market\" /> ";
		} else {
			echo "";
		}
	?>
</div>
</div>
<?					
				echo "</td>
				</tr>";
}// End No Items
}	
				echo "</table></form>
				<br />";
}

 

 

The problem is, the form can be repeated several times on a single page. When it is submitted, it always refers to the first form on the page.

 

I don't understand why as the form is ended with </form> on each one, so why does it think it's the same form everytime?

 

Is there an easy fix to this?

 

Thanks,

Nick.

I assume your printing out the form in a loop? Well from what I can tell, although I cant see the start of the function, you seem to be printing </form> after the loop..

 

				echo "</td>
				</tr>";
}// End No Items
}	
				echo "</table></form>
				<br />";

 

Try changing it to:

 

				echo "</form></td>
				</tr>";
}// End No Items
}	
				echo "</table>
				<br />";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.