javascript - remain the value of input after hide -
i have edit function function has hide/show if click edit. problem how can remain value of row if im going hide it?
for example have dialog
and decided edit sample 1(first row)
and decided realize dont want edit sample 1 close (by clicking edit again) want edit sample 5 got error
here script
//show , hide update button checker function update_contain(){ var row = jquery(".beneficiaries_rows input[type='text']:visible").length; if(row > 0){ jquery('.ui-dialog-buttonpane button:contains("update")').button().show(); }else{ jquery('.ui-dialog-buttonpane button:contains("update")').button().hide(); } } //beneficiaries edit jquery(".edit_beneficiaries").click(function(){ var row = jquery(this).closest(".beneficiaries_rows"); var show = row.find(".hide"); var hide = row.find(".show"); if(jquery(show).is(":visible")){ jquery(show).css({"display":"none"}); jquery(hide).css({"display":"inline-block"}); }else{ jquery(hide).css({"display":"none"}); jquery(show).css({"display":"inline-block"}); } update_contain(); }); html
<table style="border: 2px solid black;margin:auto;"> <tr> <th style="width:145px;"><center>name<center></th> <th><center>action</center></th> </tr> <?php while($row1 = mysql_fetch_array($result1)){ echo "<tr class='beneficiaries_rows' id='".$row1['id']."' data-id='".$row1['ben_id']."'>"; echo "<td><input class='hide' type='text' name='bename_update' value='".$row1['name']."'></div>"; echo "<div class='show'>".$row1['name']."</td>"; echo "<td>"; echo "<center><button class='del_beneficiaries'>x</button><button class='edit_beneficiaries'>edit</button></center>"; echo "</td>"; echo "</tr>"; } ?> </table> p.s im not in english thats why im posting picture elaborate question
you'll want set text inside label this
jquery("[selector label]").html(jquery("[selector input]").val());
i suggest doing on click, before hide input.
edit; since you're not following:
jquery(".edit_beneficiaries").click(function(){ var row_display = jquery(this).parents("tr").find(".show"); var row_edit = jquery(this).parents("tr").find(".hide"); jquery(row_display).html(jquery(row_edit).val()); }); 


Comments
Post a Comment