I have a simple form and want to post this, using jQuery. In Django I have some custom code which depends on the name attribute of the form (if request.POST.get('BoekForm2'))
Here is my page:
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('form').hide();
$('img').click(function() {
$('select option').eq(this.alt-1).prop('selected','true');
$('input:last').prop('Boekform2','Volgende');
// $('form').get(0).setAttribute('name', 'BoekForm2');
$('form').submit();
})
})
</script>
<form action="" method="post">
<div style='display:none'>
<input type='hidden' name='csrfmiddlewaretoken' value='ee47602b5994f986b0e6bfa5b814096c' /></div>
<label for="id_Type_activiteit">Type activiteit:</label>
<select name="Type_activiteit" id="id_Type_activiteit">
<option value="1" selected="selected">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
<input type="submit" name="BoekForm2" value="Volgende" id="BoekForm2"/>
</form>
<img style="cursor:pointer" src="../image1.jpg" alt="1" />
<img style="cursor:pointer" src="../image2.jpg" alt="2" />
<img style="cursor:pointer" src="../image.jpg" alt="3" />
When I post this form manually the POST info looks like:
Type_activiteit u'1'
csrfmiddlewaretoken u'ee47602b5994f986b0e6bfa5b814096c'
BoekForm2 u'Volgende'
When I post this form using jQuery the POST info looks like:
Type_activiteit u'1'
csrfmiddlewaretoken u'ee47602b5994f986b0e6bfa5b814096c'
How do I get the name of the form in the POST info?