Re: <input> in a while loop
uhh. if you don't want the first button to show -at all- on the form, just check what $rowR is and don't do anything if it's equal to 0?
PHP Code:
<tr>
<td align="center" valign="top" class="medium"><?php
echo "T";
if($amount[$rowR] > 1){ echo ($newRowR + 1)." - "; $newRowR=$newRowR+$amount[$rowR];}else{$newRowR++;}
echo $newRowR;
?></td>
<td align="center" valign="top" class="medium"><input name="amount[<?php echo $rowR; ?>]" type="text" value="<?php echo $amount[$rowR]; ?>" size="2" /></td>
<td align="center" valign="top" class="medium"><?php print_r ($_GET['amount']); ?></td>
<?php if($rowR != 0): ?>
<td align="center" valign="top" class="medium">
<input type="submit" name="deleteRow[<?php echo $rowR ?>]" value="X" />
</td>
<?php endif; ?>
<td align="center" valign="top" bgcolor="#CCCCCC" class="medium"> </td>
</tr>
I'm not sure if this is what you're asking for, though.
from what you explained, the only thing I can think of is when you hit enter when you're editing, say, the 6th item, the 0th item is being submitted?
Re: <input> in a while loop
Thanks for your reply. Your quite right what I had in mind isn't going to work Doh! My problem is that I've managed to identify which row the 'X' button is clicked on but if I input something in to a text box an submit the first 'X' box also gets submitted!
If I change the input type to hidden (before the first button it doesn't get picked-up, after the button and it I cann't identify which button)It doesn't help!?
Re: <input> in a while loop
I'm still not completely understanding the problem you're having. but I'll give it a go!
it looks like you're using one <form> for this entire debacle, right? well, that could explain what's going on. so, what's wrong with using multiple forms? you obviously want data being submitted on the 6th line not to include anything on the 0th line, so do that. just move your <form> tag and </form> tag within your while loop -- or is this not something you can do?
Re: <input> in a while loop
All the information is in one table / one form, I think this is needed because if a rows height is expanded (adding things to the other columns) everything in the row stays aligned with each other.
I could put a form in each cell?? But I can't see that improving my problem? Just making my code harder to read :confused:
Re: <input> in a while loop
having multiple <form> tags for every cell, every row, or every table won't change how the table displays.
I suggested this because you're saying that button[0] is showing as submitted when you're submitting button[6]. this is weird and shouldn't be happening, and I have no idea why it is happening -- I can't just take the incomplete script you posted and run it and see what's happening. but I did take some of your script and modified it so that it would run, and didn't experience what you're describing. I typed a value into an input[4] and hit button[4] and amount[4] and deleterow[4] were both set, no deleterow[0]. then, I typed something in both input[0] and input[4] and hit button[4] and had the same result but with amount[0] defined as well (but still, no deleterow[0]).
if they were all on different forms, then this wouldn't have any chance of happening.
also, I just realized that on your <form> tag you spelled method wrong (as methord). this is making your form submit as get instead of post.
I'm not sure where else to go with this.
Re: <input> in a while loop
Sorry,
If i submit with a button it records which button I'm using OK.
The problem is when i enter something in one of the text boxes and hit enter.
The whole form gets sent which means that not only do I get to record what has been entered into the text box but also the first button gets sent as being pressed.
This isn't good because I'm looking to turn the buttons into delete buttons which will delete the first row every time I enter a value in a text box.
Doh!
I was wondering why the form method was sending as GET. I think I'll keep it an just tidy-up the code to read properly.
Thanks.
Re: <input> in a while loop
I'm finding that with multiple other buttons on the same form I can single out what is being pressed and what isn't.
Is there an alternative to <textarea> that could be a better option?
! I could Include A submit button that would mean I wouldn't have to use the [return key] in the textbox to submit the form !
Can I submit a form with a button thats not on the form (being submitted)?
Thanks!
Re: <input> in a while loop
you might be able to force it to submit via javascript but I've never tried.
I still don't see why you can't just make separate forms for every row. you don't want the entire form being sent, you want just one. if the form only has two elements, then if you have input[1] selected and hit enter while you're typing into it, button[1] will be submitted no matter what. the only values that would be submitted then are amount[1] and deleterow[1]. it sounds like it would be a whole lot easier than what you're trying to think up:
PHP Code:
<table>
<?php for($i = 0; $i < 6; $i++): ?>
<form action="whatever.php" method="post">
<tr>
<td><?php echo $i; ?>
<td><input type="text" name="amount[<?php echo $i; ?>]" /></td>
<td><Input type="submit" name="deleterow[<?php echo $i; ?>]" value="X" /></td>
</tr>
</form>
<?php endfor; ?>
</table>