我有一些JSON对象,我正在填充到物料编号的第一个下拉列表中。其中一些物料编号具有多个位置。我希望能够从第一个下拉列表中选择一个物料编号,然后从第二个下拉列表中选择一个物料编号,以填充物料编号的位置。例如,当我在第一个下拉列表中选择905-830005时,我需要在第二个下拉列表中显示PROD和STERILE-PK选项。
JSON://在下面的JQUERY中声明为RfqData
image = cv2.resize(image, (360,360))
HTML:
DECLARE len INT64 DEFAULT ARRAY_LENGTH(primary_id_list);
LOOP
IF len <= 0 THEN
LEAVE;
END IF;
# TODO: find way of string variable insertion
CREATE OR REPLACE MODEL `bigquery_ml.${primary_id_list[ORDINAL(len)])}`
OPTIONS(
MODEL_TYPE='LINEAR_REG',
MAX_ITERATIONS=10
) AS
SELECT
some_label AS label,
IFNULL(some_feature, 0) AS some_feature
FROM
`example.example_table_${some_variable_suffix}`;
SET len = len - 1;
END LOOP;
JQUERY:// RfqData是我上面的JSON字符串
[
{"material":"900-100049","location":"STERILE-PK"},
{"material":"900-100050","location":"STERILE-PK"},
{"material":"900-110005","location":"PROD"},
{"material":"900-600030","location":"STERILE-PK"},
{"material":"900-600031","location":"STERILE-PK"},
{"material":"905-830005","location":"PROD"},
{"material":"905-830005","location":"STERILE-PK"},
{"material":"905-830006","location":"PROD"},
{"material":"905-830006","location":"STERILE-PK"},
{"material":"905-860008","location":"STERILE-PK"},
{"material":"905-860009","location":"STERILE-PK"}
]
答案 0 :(得分:2)
$("#selectMaterial").change( function(){
var item = "";
$("#selectLocation").empty();
$.each(json, function () {
if ($(this).val() == /*the material on json*/){
item += '<option value="' + /*your value*/ + '">' + /*your value*/ + '</option>'
}
});
$('#selectMaterial').html(item);
});
答案 1 :(得分:2)
$('#selectMaterial').on('change',GetSelectLocation);
function GetSelectLocation() {
//Here you get the selected materialId of your selectMaterial dropdown.
var selectedMaterialId = $('#selectMaterial option:selected').val();
//Now you must have your original list here. And using the above id fetch the list of location and create a location list.
var locationList = //fetch location list.
$('#selectLocation').html("");
$.each(locationList , function () {
$('#selectLocation').append(
$("<option></option>").text(this.location));
}