开发者

i want particular checkbox to get tick when text is written in textbox? which method or event is used for this?

开发者 https://www.devze.com 2023-03-07 18:52 出处:网络
I have 7 textboxand 7 corresponding checkbox if user input in any of the text boxits particular checkbox should get tick and selected textboxes text will be posted for query by click of aSearch button

I have 7 textbox and 7 corresponding checkbox if user input in any of the text box its particular checkbox should get tick and selected textboxes text will be posted for query by click of a Search button how to do it..via C#.net? which method or event should i use to check for this condition. Is i have to do it on page_load event with viewstate? Suggest me what to do thanks in advance...

Searching Filters   Title 开发者_如何学Go Description Category * Location Sources Keywords Date From

* * Date Upto

* *

*        


to detect the input text change, you can do that with the help of JQuery. u should look at http://api.jquery.com/change/ here for .change() method for text inputs.

EDIT :

here is an on-the-fly example;

<html>
<head>
<title>JQuery Test</title>
</head>
<body>

Name : <input type="text" id="txtName" /> <input type="checkbox" id="chxName" /><br/><br/>
Surname : <input type="text" id="txtSurname" /> <input type="checkbox" id="chxSurname" /><br/><br/>

<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.min.js"></script>

<script type="text/javascript">

$(document).ready(function(){

    $('#txtName').change(function(){

      var poo = $(this).val();
      var foo = $('#chxName');
      if(poo == 'bar'){
        if(!foo.is(':checked')) {
          foo.attr('checked','checked');
        }
      } else {
        if(foo.is(':checked')) {
          foo.removeAttr('checked');
        }
      }

    });

});

</script>
</body>
</html>

run this example and enter 'bar' inside the first textbox. u will see the first checkbox has been ticked. then enter another word except 'bar'. u will see the first checkbox has been unticked.

Also you can consider some of the other jQuery events like keyup, keydown or keypress

0

精彩评论

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