开发者

MVC-entering text into textbox with on click event

开发者 https://www.devze.com 2023-02-03 04:40 出处:网络
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

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

精彩评论

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

关注公众号