Good day.
When I use the following code, it sends all forms on the page, instead of just the one form I specified.
$('.imagetemp').on('change',function(){
var id = this.id;
var arr = id.split('upload');
var count = arr[1];
var form = '#imagetempform' + count;
$("form").ajaxForm(
...
...
...
Tell me please how to send just one form?
As form is a variable, you need to change:
$("form")
To:
$(form)
Otherwise you're referencing all form elements on the page as a variable wrapped in quotes is no longer a variable - it's a string, which $() interprets as a jQuery selector.
Refer to jQuery's Element Selector ("element") documentation for more info.
Edit: (from edited question):
P.S.: $(form).ajax() not work test this you can see here http://testwork.ru/10006/template1.php (before image click on button 'выбрать')...
This is because your forms have no IDs.
<form name="imagetempform1" class="..." ... >...</form>
# is used to select IDs. You can either add the IDs in:
<form name="imagetempform1" id="imagetempform1" class="..." ... >...</form>
Or you can change your selector to select the name instead with:
var form = "[name='imagetempform" + count + "']";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With