Hello all,
have a little problem getting some buttons to work.
OK, I have a form, with some submit-buttons that dynamically reproduce some input fields, I had a hard time getting them to work the way I wanted, no they do.
My problem is now, that the caption on the button is not the one I want them to have, because the "value" is now the variable I need to identify it in the catch-routine after submit, and this is only numbers.
OK, I know this sounds a little weird, so let me give you a little of the code to clarify the problem:
as it was:
<form>
.....
some fields
.......
for( $i = 0; $i <= $a; $i++){
echo "<table id ='group[" . $i . "]' name='group[" . $i . "]' border='1' cellspacing='0' cellpadding='1'>
<tbody>
<td>Name:</td>
<td><input type='text' id=name[" . $i . "]' name=name[" . $i . "]' value=\"" . $name[$i] . "\" ></td>
</tr>
.......
some more fields
.......
<tr>
<td>
<input type='submit' id=name='plus_btn' name='plus_btn' value = ' + ' >
</td>
</tr>
</table>
</form>
OK, the problem with this one is that if you have say 5 of these tables, and you pressed the the +-buton of the third table, no matter what, the sender does not get identified after reload. To solve the problem I played with the name, etc. Finally I found out that there is no other way than changing the button code to look like this:
<input type='submit' id=name='plus_btn' name='plus_btn' value =".$i" >
This way the catch routine could identify the button the submit came from. This looks like this:
if( isset( $POST['plus_btn'] ) ){
$temp = $POST['plus_btn']; //this returns the integer identifying the button
DO SOMETHING WITH $temp;
}
This is the functionality I wanted so far. But the caption of the buttons is the integer value of $i now. A user can't see what the button is used for. No problem, I said, use a GIF to hide it:
<input type='submit' src='plus.gif' id=name='plus_btn' name='plus_btn' value =".$i" >
This doesn't work, the image doesn't show up, so I changed it to type "image", now the catch-routine doesn't Identify the button any more, because the value is ignored, so I looked around again and cahnged it to look like this:
<button type='submit' id='plus_btn' name='plus_btn' value=".$i."><img src='plus.gif'></button>
Now the catch routine returns "<img src='plus.gif'>", which is not desired.
Can anybody tell me how to get the "+" shown on the button, but getting the integer value of $i returned?
No matter if the "+" comes from a picture or is just the letter.
Would appreciate any help.
Thanks in advance
gaucho