Nositi Posted July 12, 2008 Share Posted July 12, 2008 Hi, I've been toying with this a bit. I have a list, generated from database output, of names paired with emails. Along with each name/email tuple I want to have a button which should POST the name + email pairs such that I can deal with them when the page reloads. Simple enough. The problem I'm running into is the fact that I don't know how many rows of data I will have. Therefore I can't just statically name any of the form items. I've tried, as the data is being outputted from the query, keeping track of what row I'm on and simply appending this to the name + id of the submit form items. However, this doesn't seem to be allowed as the button is not recognized as having been clicked once the page reloads. How can I get around this? I know this is probably a simplistic issue and I've tried searching, but all that I can find on dynamic forms is not applicable. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/114359-solved-dynamic-number-of-forms-trying-to-determine-which-form-button-was-clicked/ Share on other sites More sharing options...
rmbarnes82 Posted July 12, 2008 Share Posted July 12, 2008 Hi, Is the reason you need to know which button was clicked so you know which row in the database the submitted tuple refers too? Robin Quote Link to comment https://forums.phpfreaks.com/topic/114359-solved-dynamic-number-of-forms-trying-to-determine-which-form-button-was-clicked/#findComment-588090 Share on other sites More sharing options...
Nositi Posted July 12, 2008 Author Share Posted July 12, 2008 Hi, Is the reason you need to know which button was clicked so you know which row in the database the submitted tuple refers too? Robin Yes, this is correct. The button is to delete the row from the database. Quote Link to comment https://forums.phpfreaks.com/topic/114359-solved-dynamic-number-of-forms-trying-to-determine-which-form-button-was-clicked/#findComment-588092 Share on other sites More sharing options...
rmbarnes82 Posted July 12, 2008 Share Posted July 12, 2008 Hi, For form containing a tuple, also generate a hidden form field inside the given form containing the primary key (id) for that row in the database. E.g.: <input type="hidden" name="row_id" value="$rowId" /> Then the submitted row_id value is the id you want to use in the where clause of your delete statement. Robin Quote Link to comment https://forums.phpfreaks.com/topic/114359-solved-dynamic-number-of-forms-trying-to-determine-which-form-button-was-clicked/#findComment-588093 Share on other sites More sharing options...
Nositi Posted July 12, 2008 Author Share Posted July 12, 2008 Oh, right, good idea. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/114359-solved-dynamic-number-of-forms-trying-to-determine-which-form-button-was-clicked/#findComment-588108 Share on other sites More sharing options...
Nositi Posted July 12, 2008 Author Share Posted July 12, 2008 Actually, that didn't quite do it. I'm still having the same issue: I can't put something generated dynamically into the value of an input. ie if I just put value="$rowId" the value will be exactly that, $rowId. If this had worked, it should work just the same to call them name1, name2, name3, etc. And this doesn't work either: value="<?php $rowId ?>" Quote Link to comment https://forums.phpfreaks.com/topic/114359-solved-dynamic-number-of-forms-trying-to-determine-which-form-button-was-clicked/#findComment-588119 Share on other sites More sharing options...
chronister Posted July 12, 2008 Share Posted July 12, 2008 Try this.... value="<?php echo $rowId ?>" You have to echo it... just adding $rowId does nothing as it is just a placeholder for a value... you have to explicitly echo that variable. Nate Quote Link to comment https://forums.phpfreaks.com/topic/114359-solved-dynamic-number-of-forms-trying-to-determine-which-form-button-was-clicked/#findComment-588124 Share on other sites More sharing options...
Nositi Posted July 12, 2008 Author Share Posted July 12, 2008 Aye, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/114359-solved-dynamic-number-of-forms-trying-to-determine-which-form-button-was-clicked/#findComment-588126 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.