Доброе время суток!
Есть JS код, он выводит параметры для категорий. выглядит примерно вот так
если леговые авто поменять на другое, то другие параметры появятся.
Так вот в чем проблема, когда я выбираю все данные которые мне нужна, я незнаю по каким запросом POST их передают в форме.
если кто может подсказать каждый name из этих select, буду благодарен, код js здесь глянуть можно.
<script type="text/javascript" src="http://doska.ykt.ru/media/js/jquery-1.8.3.min.js?64" charset="utf-8"></script>
<script type="text/javascript" src="http://doska.ykt.ru/media/js/funcs.js?64%22" charset="utf-8"></script>
<script type="text/javascript" src="http://doska.ykt.ru/catsjson.jsjsp?outVar=CATS_JSON&region=yakutsk" charset="utf-8"></script>
<table class="newpost-params" cellpadding="0" cellspacing="0">
<tr>
<td class="title">-</td>
<td>
<select class="region-select-add" name="region" id="regions" onchange="regionChange(this)">
<option value="ya" selected="selected">Я</option>
</select>
</td>
</tr>
<tr>
<td class="title">-</td>
<td class="input cats">
<script type="text/javascript">
<!--
var CATS_VALUES_JSON = {"sid":"-1","rid":"-1","cid":"-1"}
//var CATS_JSON = cat json data; // set from catsjson.js
var CAT_URL_PARAM_NAME = "cid";
var SUBCAT_URL_PARAM_NAME = "sid";
var RUB_URL_PARAM_NAME = "rid";
/*controls*/
var REGIONS_SELECT;
var CATS_SELECT;
var SUBCATS_SELECT;
var RUBRICS_SELECT;
var OPTIONS_CONTAINER;
var MAIN_OPTIONS_CONTAINER;
var CURRENT_CAT;
var LAST_RUB_NAME;
var MAIN_OPT_ID = -1;
var LOWER_YEAR_OPT_ID = -1;
var UPPER_YEAR_OPT_ID = -1;
function fillCats(CATS_JSON) {
fillSelect(CATS_SELECT, CATS_JSON, true);
var catId = null;
if (CATS_VALUES_JSON.cid != undefined) {
catId = CATS_VALUES_JSON.cid;
} else {
catId = getUrlParam(CAT_URL_PARAM_NAME);
}
setSelectValue(CATS_SELECT, catId);
onCatsChanged();
}
function renewCurrentCat() {
var currentCatId = CATS_SELECT.val();
CURRENT_CAT = getCatById(currentCatId);
var priceEl = $("#price");
if (CURRENT_CAT.showPrice) {
priceEl.show();
} else {
priceEl.hide();
}
}
function fillSelect(el, selectData, isClear) {
if (isClear && el) {
el.empty();
}
$.each(selectData, function (i, item) {
el.append($("<option>", {
value: item.id,
text: item.name,
isPriceRequired: item.isPriceRequired,
minPriceLength: item.minPriceLength,
hasLimitation: item.hasLimitation
}));
});
}
function resetSubCats() {
fillSelect(SUBCATS_SELECT, CURRENT_CAT.subcats, true);
var subCatId = null;
if (CATS_VALUES_JSON.sid != undefined) {
subCatId = CATS_VALUES_JSON.sid;
} else {
subCatId = getUrlParam(SUBCAT_URL_PARAM_NAME);
}
setSelectValue(SUBCATS_SELECT, subCatId);
var currentSubCat = getCurrentSubCat();
resetRubrics(currentSubCat);
resetOptions(currentSubCat);
}
function getCurrentSubCat() {
var selectedSubCatId = SUBCATS_SELECT.val();
return getSubCatById(CURRENT_CAT, selectedSubCatId);
}
function getCatById(id) {
var result = null;
$.each(CATS_JSON, function (i, item) {
if (item.id == id) {
result = item;
return false;
}
});
return result;
}
function getSubCatById(cat, subCatId) {
var result = null;
$.each(cat.subcats, function (i, item) {
if (item.id == subCatId) {
result = item;
return false;
}
});
return result;
}
function resetRubrics(subCat) {
if (subCat.id > 0) {
fillRubrics(subCat.rubrics);
} else {
fillRubrics(getRubricsByCat(CURRENT_CAT));
}
setRubricSelected();
}
function fillRubrics(rubrics) {
fillSelect(RUBRICS_SELECT, rubrics, true);
}
function getRubricsByCat(cat) {
var rubricsJson = [];
$.each(cat.subcats, function (i, subcat) {
$.each(subcat.rubrics, function (j, rubric) {
if (!isRubricExist(rubricsJson, rubric)) {
rubricsJson.push({id: rubric.id, name: rubric.name});
}
});
});
return rubricsJson;
}
function isRubricExist(rubricsJson, rubric) {
var result = false;
$.each(rubricsJson, function (i, item) {
if (item.id == rubric.id || item.name == rubric.name) {
result = item;
return false;
}
});
return result;
}
function setRubricSelected() {
if (LAST_RUB_NAME != undefined) {
setSelectValueByText(RUBRICS_SELECT, LAST_RUB_NAME);
} else {
setRubricsSelectValue(RUBRICS_SELECT);
}
}
function onRegionsChanged() {
fillCats(CATS_JSON);
}
function onCatsChanged() {
renewCurrentCat();
resetSubCats();
}
function onSubCatsChanged() {
var currentSubCat = getCurrentSubCat();
resetRubrics(currentSubCat);
resetOptions(currentSubCat);
}
function onRubricsChanged() {
if (RUBRICS_SELECT.selectedIndex > 0) {
LAST_RUB_NAME = RUBRICS_SELECT.item(RUBRICS_SELECT.selectedIndex).text;
}
}
function resetOptions(subCat) {
OPTIONS_CONTAINER.empty();
var isShowOpts = subCat.options.length > 0;
var optsContainerEl = $("#subcat-opts-container");
if (isShowOpts) {
optsContainerEl.show();
} else {
optsContainerEl.hide();
}
$.each(subCat.options, function (i, opt) {
var isRenderOptControl = true;
isRenderOptControl = opt.id > 0;
if (isRenderOptControl) {
var optControl = createOption(opt);
var container = OPTIONS_CONTAINER;
container.append(optControl);
var selectedVal = getUrlParam(opt.id);
if (CATS_VALUES_JSON.hasOwnProperty(opt.id)) {
selectedVal = CATS_VALUES_JSON[opt.id];
}
setSelectValue(optControl, selectedVal);
optControl.trigger("change");
}
});
}
function createOption(option) {
var optControl = $("<select>", {
id: option.id,
name: option.id
});
optControl.addClass("ui-input-select ui-input-select__state-small ui-input-select__size3");
if (option.valId) {
optControl.attr("valId", option.valId);
}
var optionName = option.name;
optControl.append($("<option>", {
value: -1,
text: "-- " + optionName + " --"
}));
$.each(option.values, function (i, item) {
optControl.append($("<option>", {
value: item.id,
text: item.name
}));
if (item.depOpts != undefined) {
var createDepOptsContainer = function (selectedVal) {
var container = $("#dep-opts-" + item.optId);
var isContainerExist = container.length > 0;
if (selectedVal < 1) {
if (isContainerExist) {
var depOptControl = $('*', container).first();
depOptControl.get(0).options.length = 1;
depOptControl.attr({"disabled": true});
}
} else if (selectedVal == item.id) {
if (isContainerExist) {
container.empty();
} else {
container.remove();
container = $("<span>", {
id: "dep-opts-" + item.optId
});
container.insertAfter(optControl);
}
}
return container;
};
var showDepOpts = function (depOpts, selectedVal) {
$.each(depOpts, function (i, depOpt) {
var depOptControl = createOption(depOpt);
var container = createDepOptsContainer(selectedVal);
container.append(depOptControl);
var presetSelectedVal = getUrlParam(depOpt.id);
if (CATS_VALUES_JSON.hasOwnProperty(depOpt.id)) {
presetSelectedVal = CATS_VALUES_JSON[depOpt.id];
}
if (presetSelectedVal != null) {
selectedVal = presetSelectedVal;
}
setSelectValue(depOptControl, selectedVal);
});
};
optControl.change(function () {
var selectedVal = optControl.val();
if (selectedVal == item.id) {
showDepOpts(item.depOpts, selectedVal);
} else if (selectedVal < 1) {
createDepOptsContainer(selectedVal);
}
});
}
});
return optControl;
}
function initCategoriesSelect() {
/* html selects */
CATS_SELECT = $("#cats");
SUBCATS_SELECT = $("#subcats");
RUBRICS_SELECT = $("#rubrics");
OPTIONS_CONTAINER = $("#search-subcat-options");
if (CATS_VALUES_JSON.cid != undefined) {
JSON_CAT_ID = CATS_VALUES_JSON.cid;
}
fillCats(CATS_JSON);
CATS_SELECT.change(onCatsChanged);
SUBCATS_SELECT.change(onSubCatsChanged);
RUBRICS_SELECT.change(onRubricsChanged);
}
//-->
</script>
<select id="cats" name="cid" ></select>
<select id="subcats" name="sid" ></select>
<select id="rubrics" name="rid" ></select>
</td>
</tr>
<tr id="subcat-opts-container" style="display: none;">
<td>Параметры</td>
<td>
<div id="search-subcat-options"></div>
</td>
</tr>
<script type="text/javascript">
initCategoriesSelect();
</script>
</table>