Jump to content

Multiple submit buttons on dynamic form


feign3

Recommended Posts

I have a loop creating a list of vendors that have orders placed for their products. The user needs to ability to send each vendor their respective orders so the loop displays a row with the vendor's name and a button that says something like "SEND ORDERS".

 

The table rows are being built with a WHILE loop and I am passing form data elements like the vendor id (main key), vendor email and name from hidden form fields.

 

However, when there are multiple rows/vendors listed on the page and I click the first "SEND EMAIL" button for example, it sends the data elements from the LAST vendor record instead. The closest I got to fixing it was to assign the vendor id to the VALUE of the button but all of the hidden elements still pass the value of the last record on the page.

 

Here is my loop code:

 

<table width="100%"  border="0" cellspacing="0" cellpadding="3">
<?php 	
while ($row_GetVendors = mysql_fetch_assoc($GetVendors)){ ?>

  <tr>
	<td width="18%"><?php echo $row_GetVendors['vendor_name']; ?></td>
	<td width="22%">(<?php echo $row_GetVendors['count(oel.vendor_notify_flag)'].' ITEMS TO SEND'; ?>) </td>
	<td width="60%"><input name="button" type="submit" id="button" value="SEND VENDOR EMAIL">
	<input name="vendor_email" type="hidden" value="<?php echo $row_GetVendors['contact_email']; ?>">
	<input name="vendor_name" type="hidden" value="<?php echo $row_GetVendors['vendor_name']; ?>">
	<input name="vendor_id" type="hidden" value="<?php echo $row_GetVendors['vendor_id']; ?>">
	<input type="hidden" name="FormUpdate" value="send_email">
	</td>
  </tr>
  <tr>
	<td colspan="3"><img src="/images/blue_spacer.gif" width="100%" height="1">    
  </tr>

<?php } ?>
</table>

 

So in the example above, I get 2 rows (one for each vendor that has orders). If I click the first button, it sends all of the values from the second row instead.

 

Here is the generated HTML:

 

<table width="100%"  border="0" cellspacing="0" cellpadding="3">

  <tr>

	<td width="18%">Vendor 1 Name</td>
	<td width="22%">(1 ITEMS TO SEND) </td>
	<td width="60%"><input name="button" type="submit" id="button" value="SEND VENDOR EMAIL">
	<input name="vendor_email" type="hidden" value="craig@email.com">
	<input name="vendor_name" type="hidden" value="Vendor 1 Name">
	<input name="vendor_id" type="hidden" value="2">
	<input type="hidden" name="FormUpdate" value="send_email">
	</td>

  </tr>
  <tr>
	<td colspan="3"><img src="/images/blue_spacer.gif" width="100%" height="1">    
  </tr>


  <tr>
	<td width="18%">Vendor 2 Name</td>
	<td width="22%">(6 ITEMS TO SEND) </td>

	<td width="60%"><input name="button" type="submit" id="button" value="SEND VENDOR EMAIL">
	<input name="vendor_email" type="hidden" value="email@email.com">
	<input name="vendor_name" type="hidden" value="Vendor 2 Name">
	<input name="vendor_id" type="hidden" value="1">
	<input type="hidden" name="FormUpdate" value="send_email">
	</td>
  </tr>
  <tr>
	<td colspan="3"><img src="/images/blue_spacer.gif" width="100%" height="1">    
  </tr>

</table>

 

I'm sure this has to do with the way the form works with using multiple submits or something. Does anyone know a good way to do this that still allows me to use submit buttons as opposed to radio buttons and such?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.