商品リストがあり、価格は通常のテキストです。価格でクリックすると、テキストを入力に置き換えたいと思います。ぼかしイベントを呼び出すと、DB データが更新され、入力がテキストに置き換えられます。
私はこのコードを持っています:
<td>
<span onclick="make_field(this, 'text', '11', '12,350.00')">12,350.00</span> €
</td>
<script>
function make_field(el, type, id, val) {
var el = $(el);
el.html('<input onblur="update_db_row(params); make_el(this, \'span\', ' + id + ', \'' + val + '\', \'' + **this.value** + '\')" type=' + type + ' name=' + id + ' value="' + val.replace(',',' ').replace(',',' ').replace('.',',') + '">'); // replace 12,350.00 to 12350,00
el.attr('onclick', '');
}
function make_el(el, tag_name, id, old_value, **new_value**) {
var el = $(el);
alert(old_value);
alert(new_value); // undefined, how I can give current input value to function when I click outside the input?
}
</script>
ありがとう。