Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# MVC4,选择自动完成值时如何填充3个文本框?_C#_Javascript_Jquery_Asp.net_Json - Fatal编程技术网

C# MVC4,选择自动完成值时如何填充3个文本框?

C# MVC4,选择自动完成值时如何填充3个文本框?,c#,javascript,jquery,asp.net,json,C#,Javascript,Jquery,Asp.net,Json,我有一个表单,它有一个文本框,我已经在表单上附加了autocomplete,但是我不知道如何在选择值时触发ActionResult(它返回json),并获取json结果并将其放入文本框中。 除此之外,在相同的形式下,我有一个下拉列表,我想当我选择一个值时,这个下拉列表会被填充,还有其他3个文本框 这是选择下拉列表时返回的JSON结果: [{“价格”:112,“折扣”:0,“产品类型列表”:[{“产品类型ID”:3,“产品ID”:1,“用户ID”:2,“类型”:“1kg”,“FLEX_FLD1”:

我有一个表单,它有一个文本框,我已经在表单上附加了autocomplete,但是我不知道如何在选择值时触发ActionResult(它返回json),并获取json结果并将其放入文本框中。 除此之外,在相同的形式下,我有一个下拉列表,我想当我选择一个值时,这个下拉列表会被填充,还有其他3个文本框

这是选择下拉列表时返回的JSON结果:

[{“价格”:112,“折扣”:0,“产品类型列表”:[{“产品类型ID”:3,“产品ID”:1,“用户ID”:2,“类型”:“1kg”,“FLEX_FLD1”:null,“FLEX_FLD2”:null,“FLEX_FLD3”:null,“FLEX_FLD4”:null,“FLEX_FLD5”:null}],“disuntType”:“百分比”}]

ProductTypeList
项目是我想放在第二个
dropdownlist
中的项目,价格、折扣和百分比则放在3个
文本框中

谢谢你的帮助

编辑:


@LabelFor(model=>model.CustomerNo)
@Html.TextBoxFor(model=>model.CustomerNo,新的{@data\u cdp\u autocomplete=@Url.Action(“autocomplete”)})
@ActionLink(“添加新客户”、“创建客户”、“客户”)
@Html.ValidationMessageFor(model=>model.CustomerNo)
@LabelFor(model=>model.CustomerName)
@EditorFor(model=>model.CustomerName)
@Html.ValidationMessageFor(model=>model.CustomerName)
@LabelFor(model=>model.CustomerAddress)
@EditorFor(model=>model.CustomerAddress)
@Html.ValidationMessageFor(model=>model.CustomerAddress)
@LabelFor(model=>model.CustomerPAACI)
@EditorFor(model=>model.CustomerPAACI)
@Html.ValidationMessageFor(model=>model.CustomerPAACI)
@LabelFor(model=>model.ItemName)
精选产品
@*迭代类别视图模型*@
@foreach(模型中的var项目)
{         
@item.ItemName
}
其他
@Html.Label(“项目大小”)
选择大小
其他
@LabelFor(model=>model.Quantity)
@EditorFor(model=>model.Quantity)
@Html.ValidationMessageFor(model=>model.Quantity)
@LabelFor(model=>model.Price)
@EditorFor(model=>model.Price)
@Html.ValidationMessageFor(model=>model.Price)
var submitaToCompleteForm=函数(事件,用户界面){
var$input=$(此);
$input.val(ui.item.label);
var$form=$input.parents(“form:first”);
$form.submit();
};
var createAutocomplete=函数(){
var$input=$(此);
变量选项={
来源:$input.attr(“数据cdp自动完成”),
选择:SubmitaToCompleteForm
};
$input.autocomplete(选项);
};
$(“form[data cdp ajax='true']);
$(“输入[数据cdp自动完成]”)。每个(创建自动完成);
这位于js文件中,在提交第一个表单后刷新页面,这不是一个好主意


我是jquery新手。您能否为我展示一些适合此场景的jquery解决方案。

我想,当您的视图中发生事件时,您需要填充三个文本框:

你可以这样做

<div class="three-textbox">
            <fieldset>
                <div class="editor-label">
                price
                </div>
                <div class="editor-field">
                <input type="text" id="price" name="price" />
                </div>
                 <div class="editor-label">
                discount
                </div>
                <div class="editor-field">
                <input type="text" id="discount" name="discount" />
                </div>
                 <div class="editor-label">
                percentage
                </div>
                <div class="editor-field">
                <input type="text" id="percentage" name="percentage" />
                </div>
                </fieldset>
            </div> 

能否显示视图/页面和代码JQuery?
<div class="three-textbox">
            <fieldset>
                <div class="editor-label">
                price
                </div>
                <div class="editor-field">
                <input type="text" id="price" name="price" />
                </div>
                 <div class="editor-label">
                discount
                </div>
                <div class="editor-field">
                <input type="text" id="discount" name="discount" />
                </div>
                 <div class="editor-label">
                percentage
                </div>
                <div class="editor-field">
                <input type="text" id="percentage" name="percentage" />
                </div>
                </fieldset>
            </div> 
$(document).ready(function(){
   $(".three-textbox").hide();
});

$('.dropone').change(function() {  //event changed function   
  $(".three-textbox").slideDown(); **OR** $(".three-textbox").show();
});