mohammad5530
یک شنبه 24 اسفند 1393, 23:10 عصر
سلام
من میخام یک فرمی داشته باشم که دو تا dropdown داره . وقتی گزینه ای در Dropdown اولی انتخاب شد ، گزینه هایی که مربوط به Dropdown اولی هست در Dropdown دومی نمایش داده بشوند .
مثلا یکی برای گروه و یکی برای مدل . Dropdown اول برای گروه و دوم برای مدل . وقتی گروهی انتخاب شد ، مدل های مربوط به اون گروه در مدل نمایش داده بشوند .
مرسی
aroshanzamir
یک شنبه 24 اسفند 1393, 23:15 عصر
سلام منظورت اینه که مثلا اگر دوتا dropdown داشته باشیم یکی استان و دیگری شهرستان باشد وقتی هر استانی انتخاب شد
شهر های مربوط به اون استان در dropdown دوم نمایش بده ؟
درست میگم ؟
mohammad5530
یک شنبه 24 اسفند 1393, 23:49 عصر
بله کاملا درسته .
این کده من هست ولی کاری انجام نمیده
@model Behdasht.Models.tbl_Kala
@{
ViewBag.Title = "افزودن کالا";
}
<script src="~/Scripts/jquery-2.1.3.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#Model").prop("disabled", true);
$("#GoroohF").change(function () {
$("#Model").text("Name");
var id = $("#GoroohF").val();
$.ajax({
cache: false,
type: "GET",
url: '@Url.Action("GetModel")',
data: { "gfid": id },
success: function (json) {
$("#Model").empty();
for (var i;i <json.length;i++)
{
$("#Model").append("<option>" + json[i].Name + "</option>");
}
$("#Model").prop("disabled" , false);
},
error: function(){
alert("مدلی در این زیرگروه پیدا نشد .");
}
})
})
})
</script>
<h2>افزودن</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>کالا</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2 pull-right" })
<div class="col-md-10">
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.GoroohFarieID, "زیرگروه", htmlAttributes: new { @class = "control-label col-md-2 pull-right"})
<div class="col-md-10">
@Html.DropDownList("GoroohFarieID", null, htmlAttributes: new { @class = "form-control", @id = "GoroohF"})
@Html.ValidationMessageFor(model => model.GoroohFarieID, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.ModelID, "مدل", htmlAttributes: new { @class = "control-label col-md-2 pull-right"})
<div class="col-md-10">
@Html.DropDownList("ModelID", null, htmlAttributes: new { @class = "form-control", @id = "Model"})
@Html.ValidationMessageFor(model => model.ModelID, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.KodelKala, htmlAttributes: new { @class = "control-label col-md-2 pull-right" })
<div class="col-md-10">
@Html.EditorFor(model => model.KodelKala, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.KodelKala, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.SazandeID, "سازنده", htmlAttributes: new { @class = "control-label col-md-2 pull-right" })
<div class="col-md-10">
@Html.DropDownList("SazandeID", null, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.SazandeID, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.AndazeGiriID, "اندازه گیری", htmlAttributes: new { @class = "control-label col-md-2 pull-right" })
<div class="col-md-10">
@Html.DropDownList("AndazeGiriID", null, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.AndazeGiriID, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.MoshakhasateTakmili, htmlAttributes: new { @class = "control-label col-md-2 pull-right" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.MoshakhasateTakmili, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MoshakhasateTakmili, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
<input type="submit" value="افزودن" class="btn btn-success" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("بازگشت به لیست", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
درسته مقدار میگیره ولی مثلا توی قسمت شهرستان چیزی نشون نمییده
aroshanzamir
دوشنبه 25 اسفند 1393, 00:07 صبح
من این سناریو را چند بار تو این انجمن مثال زدم و آپلود کردم ... الان واست آپلود می کنم
aroshanzamir
دوشنبه 25 اسفند 1393, 00:13 صبح
این هم مثال : همه چی واضح است
باز هم هر جاش مبهم بود بگو توضیح بدم
لینک دانلود (http://uplod.ir/qgdbqfb9e5r3/WebApplication_.zip.htm)
http://uplod.ir/qgdbqfb9e5r3/WebApplication_.zip.htm
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.