我要做的就是访问 array_from_php.api_description。{ACTION_VARIABLE} .PARAM
以下脚本有效:
$('select[name="action"]').change(function(){
var action = $(this).val();
var new_form = '';
$.each(array_from_php.api_description.register_mobile.param, function(i, param) {
new_form += '<label for="label">'+param+': </label>';
new_form += '<input type="text" name="'+param+'" value=""><br />';
});
$(".parameters").html(new_form);
});
但是如何将register_mobile
更改为动作变量im gettin?
答案 0 :(得分:2)
使用括号表示法:
$('select[name="action"]').change(function(){
var action = $(this).val();
var new_form = '';
$.each(array_from_php.api_description[action].param, function(i, param) {
new_form += '<label for="label">'+param+': </label>';
new_form += '<input type="text" name="'+param+'" value=""><br />';
});
$(".parameters").html(new_form);
});