开发者

MVC-entering text into textbox with on click event

I have view for entering new entity. On that view I have two buttons: one for saving new entity and another button should enter value into textbox on 开发者_StackOverflowthat form but I can't achieve this, the value in the textbox stays same as it was on page load. Does anyone know how to do this? Thx


There are two possibilities:

  1. Use javascript
  2. Reload the page with additional query string containing the new value

Example with jquery:

<input type="text" name="foo" id="foo" value="old value" />
<input type="button" id="update" value="Update value" />

and the script

$(function() {
    $('#update').click(function() {
        $('#foo').val('some new value');
    });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜