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.

1
  • 2
    Why don't you just put the select inside the form? Then you don't have to do any javascript handling at all. Commented May 3, 2012 at 23:35

1 Answer 1

2
<input type='hidden' name='current_step' value='' />
<script>
$('#current-step').on('change', function() {
    $('input[name=current_step]').attr('value', $(this).val());
});
</script>
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.