javascript - [PHP]Why did the filled appended row didn't display and show? -
this question has answer here:
this page got button add
append row.once appended row filled,when submit,it connect/link page ,then filled information display @ page.but problem how display filled information of appended row on 2nd page had been done in 1st page using php.(sorry poor english , hope understand).
<table width="600px" id="project"> <tr> <td>1</td> <td><textarea name="pro_1" cols="100" rows="2"></textarea></td> </tr> <tr> <td>2</td> <td><textarea name="pro_2" cols="100" rows="2"></textarea></td> </tr> <tr> <td>3</td> <td><textarea name="pro_3" cols="100" rows="2"></textarea></td> </tr> </table> <input id="addbtn" type="button" name="addbtn" value="add">
jquery script(for append row):
$(document).ready(function() { $("#addbtn").click(function(){ var num=parseint($("#project tr:last").text()); num+=1; $("#project").append("<tr><td>"+num+"</td><td><textarea cols='100' rows='2'></textarea></td></tr>"); });
php source code(for 2nd page):
<table width="600px" id="pub"> <tr> <td>1</td> <td><?php echo $_post["pro_1"]; ?></td> </tr> <tr> <td>2</td> <td><?php echo $_post["pro_2"]; ?></td> </tr> <tr> <td>3</td> <td><?php echo $_post["pro_3"]; ?></td> </tr> </table> <table width="600px" id="project"> <?php //to show filled appended row fail $index = 1; while(isset($_post["pro_".$index])) { ?> <tr> <td><?php echo $index; ?></td> <td><?php echo $_post["pro_".$index]; ?></td> </tr> <?php $index++; } ?> </table>
the output below:
you forgot add name
attribute append command
name='pro_'+num; $("#project").append("<tr><td>"+num+"</td><td><textarea name="+name+" cols='100' rows='2'></textarea></td></tr>");
Comments
Post a Comment