PDA

View Full Version : مشکل عجیب !! اجرا نشدن کدها در کلیک اول



na3er-faraji
دوشنبه 10 مهر 1391, 20:06 عصر
سلام . یک مشکل عجیب دارم. بار اول که روی دکمه ذخیره کلیک میکنم کار نمیکنه اما بار دوم کار میکنه . کدهای jquery رو ضمیمه میکنم . بریک پوینت که گذاشتم بار اول کلیک دستورات اجرا نشد مطمینم مشکل از دستورات سمت سرور نیست و هر چی هست زیر سر ایناس . کسی میتونه گیر کار رو پیدا کنه ؟

<script type="text/javascript">
function changeGroup(groupId) {
if (groupId != 0) {
$.ajax({
type: "POST",
url: "Post.aspx/GetGroup2",
data: "{'groupParentId': " + groupId + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
var items = "";
for (var i = 0; i < result.d.length; i++) {
var opt = result.d[i];
items += "<option value=\"" + opt.GroupId + "\">" + opt.GroupTitle + "</option>";
}
$("#<%=ddlGroup2.ClientID %>").html(items);
},
error: function (result) { alert(result.status + ' ' + result.statusText) }
});
}
else {
$("#<%=ddlGroup2.ClientID %>").html('');
}
}

function RefreshControl(groupId) {
$("#BuyPrice").hide();
$("#HousePrice").hide();
$("#infoRahn").hide();

if (groupId == 2 || groupId == 7 || groupId == 14 || groupId == 74 || groupId == 42) {
$("#BuyPrice").show();
}
else if (groupId == 36 || groupId == 47) {
$("#HousePrice").show();
$("#infoRahn").show();
}
}

function checkValidator(groupId,event) {
if (groupId == 2 || groupId == 7 || groupId == 14 || groupId == 74 || groupId == 42) {
ValidatorEnable($("#<%=rfvPrice.ClientID %>")[0], true);
ValidatorEnable($("#<%=rvPrice.ClientID %>")[0], true);
ValidatorEnable($("#<%=rfvEjare.ClientID %>")[0], false);
ValidatorEnable($("#<%=rvEjare.ClientID %>")[0], false);
ValidatorEnable($("#<%=rfvRahn.ClientID %>")[0], false);
ValidatorEnable($("#<%=rvRahn.ClientID %>")[0], false);
}
else if (groupId == 36 || groupId == 47) {

ValidatorEnable($("#<%=rfvEjare.ClientID %>")[0], true);
ValidatorEnable($("#<%=rvEjare.ClientID %>")[0], true);
ValidatorEnable($("#<%=rfvRahn.ClientID %>")[0], true);
ValidatorEnable($("#<%=rvRahn.ClientID %>")[0], true);
ValidatorEnable($("#<%=rfvPrice.ClientID %>")[0], false);
ValidatorEnable($("#<%=rvPrice.ClientID %>")[0], false);
}
else {
ValidatorEnable($("#<%=rfvEjare.ClientID %>")[0], false);
ValidatorEnable($("#<%=rvEjare.ClientID %>")[0], false);
ValidatorEnable($("#<%=rfvRahn.ClientID %>")[0], false);
ValidatorEnable($("#<%=rvRahn.ClientID %>")[0], false);
ValidatorEnable($("#<%=rfvPrice.ClientID %>")[0], false);
ValidatorEnable($("#<%=rvPrice.ClientID %>")[0], false);
}

if ($("#<%=chkEmail.ClientID %>").attr("checked") || $("#<%=chkMobile.ClientID %>").attr("checked")) {
$("#<%=lblContactType.ClientID %>").hide();
}
else {
$("#<%=lblContactType.ClientID %>").show();
event.preventDefault();
}

}

function checkPriceType() {
var priceType = $("#<%=ddlPriceType.ClientID %>").val();
if (priceType != 1) {
$("#<%=txtPrice.ClientID %>").hide();
}
else {
$("#<%=txtPrice.ClientID %>").show();
}
}

$(document).ready(function () {
//default value
$("#<%=lblContactType.ClientID %>").hide();
var groupId = $("#<%=ddlGroup1.ClientID %>").val();
RefreshControl(groupId);
checkPriceType();

$("#<%=ddlGroup1.ClientID %>").change(function () {
var groupId = $("#<%=ddlGroup1.ClientID %>").val();
changeGroup(groupId);
RefreshControl(groupId);
});

$("#<%= ddlPriceType.ClientID %>").change(function () {
checkPriceType();
});
//check type tamas
$("#<%=btnSave.ClientID %>").click(function (event) {
var groupId = $("#<%=ddlGroup1.ClientID %>").val();
checkValidator(groupId,event);
});
});


</script>

na3er-faraji
سه شنبه 11 مهر 1391, 10:45 صبح
چرا سایت برنامه نویس این طوری شده ؟ حداقل 7-8 سوال آخرم بی جوابه!!!!