1

First, I have to say that I find a similiar question: How to add a post parameter to manual form submission?.

But I think that someone can tell me a better solution.

I want to add a name parameter to a form when the user clicks the submit button, this is how I do it:

var htmlElement = '<input type="hidden" name="current_step" value="' + $('select#current-step').val() + '"/>';
elForm.append(htmlElement);

But I'm not completed satisfied whith this aproach.

Thx in advance if you give me a better way to do it.

4

1 回答 1

2
<input type='hidden' name='current_step' value='' />
<script>
$('#current-step').on('change', function() {
    $('input[name=current_step]').attr('value', $(this).val());
});
</script>
于 2012-05-03T23:59:52.297 回答