1

What I am trying to do exactly is to access array_from_php.api_description.{ACTION_VARIABLE}.param

This following script works:

$('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);

});

but how can I change the register_mobile to the action variable im gettin there?

1 Answer 1

2

By using bracket notation:

$('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);

});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.