2010-08-12 68 views
1
<script type="text/javascript" language="javascript"> 
    $(function() { 

    $("#distributor").autocomplete({ 
      source: function(request, response) { 
       $.ajax({ 
        url: "/Devices/autoDistributor", type: "POST", dataType: "json", 
        data: { name: request.term, maxResults: 10 }, 
        success: function(data) { 
         response($.map(data, function(item) { 
          return { value: item.Name } 
         })) 
        } 
       }) 
      }, 
      select: function(event, ui) { 
      //alert(ui.item.value); 

      } 
     }); 


    }); 
</script> 

    <% using (Html.BeginForm("Filtering","Devices",FormMethod.Post)) {%> 


    Distributor: <input id="distributor" type="text"/> 

    <input id="finish_button" type="submit" value="Search" /> 


    <% } %> 

當我發佈表單時,插入輸入(id =「distributor」)的文本未發佈,爲什麼?輸入的值未發佈

+0

是當你按下了進入這種情況的發生自動完成?在這種情況下,在框有機會填充值之前,默認表單提交是否可能觸發?當我按搜索按鈕時, – 2010-08-12 10:04:07

+0

表單正在提交 – Ognjen 2010-08-12 10:05:59

回答

1

<input>缺少name屬性,像這樣:

<input id="distributor" name="distributor" type="text"/> 

沒有這一點,它沒有被序列/提交時<form>確實:)