本文介绍了文本框的值是自动追加和使用jQuery的下拉列表取代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果基于以下code然后在文本框中集中了那么该文本框的值在下拉列表中追加创建4个文本框

喜的朋友其工作正常,但同时用户可以改变文本框的值我需要更换旧文本框的值,以新的价值我该怎么办这个,请帮助我的朋友

我的文本框中创建和下拉创作

 <%的for(int i = 0; I< Convert.ToInt16(Model.NumGroups);我++)
           {%GT;
       &所述; TR>
       &所述; TD>
           <%:Html.Label(本集团+(I + 1)的ToString())%GT;< BR />
           <%:Html.TextBox(组名,空,新的{ID = I,@class =组名})%GT;
       < / TD>
       < / TR>
       <%}%GT;
       <%的for(int i = 0; I< Convert.ToInt16(Model.NumGroups);我++)
           {%GT;
       &所述; TR>
       &所述; TD>
           <选择类名=GroupSelect>
           <选项>< /选项>< /选择>
       < / TD>
       < / TR>
       <%}%GT;

我的jQuery

  $('组名')。事件的内容(函数(){
        VAR数据= $(本).VAL();
        VAR GET = $(本).attr('身份证');
        $('GroupSelect选项)parseInt函数(获得+ 1)] =文本数据。
    });


解决方案

,而用户可以改变文本框的值,我需要取代旧的文本框的值

尝试使用的onkeyup和的onblur。

例如:

 <%:Html.TextBox(组名,空,新的{ID = I,@class =组名的onkeyup =myonkeyup()})%GT ;<脚本>
 功能myonkeyup()
 {
  //获取当前值和放大器;更换
 }
< / SCRIPT>

hi friends if 4 text box is created based on below code then while text box focus out then that text box value are append in dropdown list its working fine but while user can change the text box value i need to replace old textbox value to new value how can i do this please help me friends

My text box Creation and dropdown creation

      <% for (int i = 0; i < Convert.ToInt16(Model.NumGroups); i++)
           { %>
       <tr>
       <td>
           <%: Html.Label("Group" + (i+1).ToString()) %><br />
           <%: Html.TextBox("GroupName", null , new { id= i, @class = "GroupName" })%>
       </td>
       </tr>
       <%} %>
       <% for (int i = 0; i < Convert.ToInt16(Model.NumGroups); i++)
           { %>
       <tr>
       <td>
           <select classname = "GroupSelect">
           <option></option></select>
       </td>
       </tr>
       <%} %>

My jquery

   $('.GroupName').focusout(function () {
        var data = $(this).val();
        var get = $(this).attr('id');            
        $('GroupSelect option')[parseInt(get + 1)].text = data;
    });
解决方案

"while user can change the text box value i need to replace old textbox value"

try using onkeyup or onblur.

Example:

<%: Html.TextBox("GroupName", null , new { id= i, @class = "GroupName", onkeyup="myonkeyup()" })%>

<script>
 function myonkeyup()
 {
  //get current value & replace
 }
</script>

这篇关于文本框的值是自动追加和使用jQuery的下拉列表取代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 21:42