...

View Full Version : Dynamic button values



h8ids
06-22-2006, 09:50 PM
Dynamically pulling data from a database.
Each record has database field data appearing within a dynamic table, along with several buttons associated to each record.
All but one of the buttons works correctly.


"Edit" - opens edit page and passes data related to the respected record.
"PDF" - opens pdf file and populates it with the respected record.
"Submit" - Calls a function to generate and send an email.
"Delete" - Deletes respected record from the database.


I'm having a problem with the Submit button.
Presently, the record page shows five records at a time; 1, 2, 3, 4, and 5.
When the "Submit" button is selected for a any one record, all "Submit" buttons react. (I have an onclick command to change their value to "Submitted".)

Example:
Record 3 is the choice record; the user clicks the "Submit" button for record 3. But instead of one email being sent, five emails are sent. (Each "Submit" button changes to "Submitted".)
All emails do reflect information related to record 3.

Can dynamic values be created for each button as PHP is pulling data from the database and generating the table? The ideal value generation would look like the following for each "Submit" button. (value="submit1", value="submit2",... value="submit5").

Not sure if a counter can handle the job.


for($i = 1; $i <= $DBrecords; $i++){
Something in here
}

Fumigator
06-22-2006, 11:18 PM
Well here's the way I'm doing it, though I don't know if it's the best way:



<?php
for ($i = 0; $i < count($myArray); $i++) {
print "<input type=\"button\" name=\"subBtn{$i}\" value=\"Submit Record #{$i}\" />\n";
}
?>


You end up with uniquely named (and labeled) buttons.

h8ids
06-27-2006, 08:38 PM
got it, thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum