If you have been on the new PHP myadmin you can click on a field and edit it then when you click away it changes back to a div, I thought this could be found on the web easy but aprently not, so I tryed to make it and I'm not very good with javascript so I failed. Heres what i got so far.
HTML:
<td id="td_1"><input type="hidden" value="0" />0</td>
Javascipt:
$("#td_1").click(function() {
$input = $("#td_1");
$field = $('<input type="text" id="txt_1" maxlength="1" size="1"/>').attr({
id: $input.id,
name: $input.name,
value: $input.val()
});
$input.after($field).remove();
});
It adds the textbox but does not add the value to it, and stuck on how to change it back
Thanks for any help :)
I would have a hidden textbox that you show when you click on the text value. Working example
HTML
<td id="td_1"><input id="txtBox" type="textbox" value="0" style="display:none;" /><span id="txtBoxValue">0</span></td>
jQuery
$(function() {
$('#txtBoxValue').on('click', function() {
$(this).hide(); //hide text
$('#txtBox').show(); //show textbox
});
$('#txtBox').on('blur', function() {
var that = $(this);
$('#txtBoxValue').text(that.val()).show(); //updated text value and show text
that.hide(); //hide textbox
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With